Tuesday, May 11, 2010

Unexpected Exception

How to specify Exception?
 func()                    // this can throw any Excpeption
 func()  throw()      // this Will NOT throw any Excpeption
 func()  throw (bad_alloc , X )  // this can throw only specified  Excpeption

unexpected() is called when function throws exception other  than specified 

It uses     _unexpected_handler  which can be changed  
unexpected_handler old_hand  = set_unexpected( newfunction);
 
void newfunction( ) 
{
   cout << "Hi" << endl;
   terminate( );
}
 

2 comments:

Followers