Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.29 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to define a run-time exception in c  ?
  2. class my_exception : public std::exception
  3. {
  4. public:
  5.  my_exception(const std::string& msg) : msg_(msg) {}
  6.  const char* what(); // override what to return msg_;
  7. private:
  8.     std::string msg_;
  9. };
  10.  
  11. //some other code..
  12.  
  13. throw my_exception("Error");