Exception Handling


// standard exceptions
//Program works in Command prompt of Visual Studio 
#include < iostream >
#include < exception >
using namespace std;

class myexception: public exception
{
  virtual const char* what() const throw()
  {
    return "My exception happened";
  }
} myex;

int main () {
  try
  {
    throw myex;
  }
  catch (exception& e)
  {
    cout << e.what() << endl;
  }
  return 0;
}
<< GO BACK

Our aim is to provide information to the knowledge seekers.


comments powered by Disqus




Footer1