#include <iostream>
#include <exception>
using namespace std;

void throwException()  {
   try { 
      cout << " Function throwException throws an exception\n"; 
      throw exception(); 
   } 
   catch ( exception & ) { 
      cout << " Exception handled in function throwException"
               << "\n Function throwException rethrows exception"; 
      throw;
    } // end catch 
    cout << "This also should not print\n"; 
}
main()
{
    // throw exception
    try
    {
      cout << "\nmain invokes function throwException\n";
      throwException();
      cout << "This should not print\n";
    } // end try
    catch ( exception & ) // handle exception
    {
       cout << "\n\nException handled in main\n";
    } // end catch
    cout << "Program control continues after catch in main\n";
    system("pause");
} // end main
