Mega Code Archive

 
Categories / C++ Tutorial / Exceptions
 

Rethrowing an exception

#include <iostream>  using namespace std;    void f()  {    try {      throw "hello"; // throw a char *    }    catch(char *) { // catch a char *      cout << "Caught char * inside f\n";      throw ; // rethrow char * out of function    }  }    int main()  {    cout << "start\n";      try{      f();    }    catch(char *) {      cout << "Caught char * inside main\n";    }      cout << "end";      return 0;  } start This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.