class Person{
public:
Person(string name){
mName = name;
cout << mName << "对象被创建!" << endl;
}
~Person(){
cout << mName << "对象被析构!" << endl;
}
public:
string mName;
};
void TestFunction(){
Person p1("aaa");
Person p2("bbb");
Person p3("ccc");
//抛出异常
throw 10;
}
int main(){
try{
TestFunction();
}
catch (...){
cout << "异常被捕获!" << endl;
}
system("pause");
return EXIT_SUCCESS;
}