What is the purpose of a function try block? [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: When is a function try block useful? Difference between try-catch syntax for function This code throws an int exception while constructing the Dog object inside class UseResources . The int exception is caught by a normal try-catch block and the code outputs : Cat() Dog() ~Cat() Inside handler #include <iostream> using namespace std; class Cat { public: Cat() { cout << "Cat()" << endl; } ~Cat() { cout << "~Cat()