Mega Code Archive

 
Categories / C++ / Language
 

Demonstration of rethrowing an exception

#include <iostream> using std::cout; using std::endl; #include <exception> using std::exception; void throwException()  {    try {       throw exception();     }     catch( exception e )    {       cout << "Exception handled in function throwException\n";       throw;      }     cout << "This also should not print\n"; }  int main() {    try {       throwException();       cout << "This should not print\n";    }catch ( exception e ){       cout << "Exception handled in main\n";    }     return 0; }