This documentation is archived and is not being maintained.

set_terminate (<exception>)

Establishes a new terminate_handler to be called at the termination of the program.

      terminate_handler _Pnew
   ) throw( );


The function to be called at termination.

The address of the previous function that used to be called at termination.

The function establishes a new terminate_handler as the function *_Pnew. Thus, _Pnew must not be a null pointer. The function returns the address of the previous terminate handler.

// exception_set_terminate.cpp
// compile with: /EHsc /c

using namespace std;

void termfunction( ) 
   cout << "I'll be back." << endl;
   abort( );

int main( ) 
   terminate_handler oldHand = set_terminate(termfunction);

   // Throwing an unhandled exception would also terminate the program
   throw bad_alloc( );

   // The program could also be explicitely terminated with:
   // terminate( );
I'll be back.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Header: <exception>

Namespace: std