Sdílet prostřednictvím


set_terminate (<exception>)

Vytvoří nový terminate_handler má být volána při ukončení programu.

terminate_handler
   set_terminate(
      terminate_handler _Pnew
   ) throw( );

Parametry

  • _Pnew
    Funkce volané při ukončení.

Vrácená hodnota

Adresa předchozí funkci, která slouží k ukončení volat.

Poznámky

Zavádí novou funkci terminate_handler jako funkce * _Pnew.Tedy _Pnew nesmí být ukazatel s hodnotou null.Funkce vrátí adresu předchozího ukončení rutiny.

Příklad

// exception_set_terminate.cpp
// compile with: /EHsc /c
#include<exception>
#include<iostream>

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( );
}
  
  
  

Požadavky

Záhlaví: <exception>

Obor názvů: std