Rethrowing an exception : throw « Exceptions « C++ Tutorial






#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.








6.2.throw
6.2.1.Throw an exception
6.2.2.Rethrowing an exception
6.2.3.Throw an exception from a function and catch it