#include #include using namespace std; class A { public: A() { cout << "A: constructor: " << endl ; } ~A() { cout << "A: destructor: " << endl ; } }; void function2() { A objectA1 ; try { cout << "Inside function2: Step 1" << endl ; throw 10 ; cout << "Inside function2: Step 2" << endl ; } catch( int& x1 ) { cout << "Inside function2: Catch Step 1" << endl ; throw x1 ; cout << "Inside function2: Catch Step 2" << endl ; } cout << "End of function2." << endl ; } void function1() { A objectA1 ; cout << "Inside function1: Step 1" << endl ; function2() ; cout << "End of function1." << endl ; //A } int main() { try { function1() ; cout << "After function 1 in main." << endl ; //B } catch ( int& x1 ) { cout << "Inside catch. main" << endl ; } cout << "End of main:" << endl ; return 0; }