#include #include #include //for uncaught_exception and set_terminate using namespace std; class pitcher { public: ~pitcher() throw (int) { if (uncaught_exception()) { try { throw 20; //This exception will not escape from the destructor. } catch (int i) { cout << "~pitcher caught int " << i << ".\n"; } } else { throw 30; //This exception will escape from the destructor. } } }; void my_terminate(); int main() { set_terminate(my_terminate); try { pitcher pit; throw 10; } catch (int i) { cout << "main caught int " << i << ".\n"; } return EXIT_SUCCESS; } void my_terminate() { cerr << "my_terminate has been called.\n"; exit(EXIT_FAILURE); }