class TestClass
{
public:
TestClass()
{
cout << "Construtor TestClass" << endl;
}
~TestClass()
{
cout << "Destructor TestClass" << endl;
}
};
class Exception1
{
public:
Exception1()
{
cout << "Construtor Exception1" << endl;
}
~Exception1()
{
cout << "Destructor Exception1" << endl;
}
};
int test()
{
TestClass t;
throw Exception1();
}
int _tmain(int argc, _TCHAR* argv[])
{
try
{
test();
}
catch (...)
{
}
return 0;
}
这个的执行结果为:
Construtor TestClass
Construtor Exception1
Destructor Exception1
Destructor TestClass
Destructor Exception1
为什么“Destructor Exception1”会执行两次啊?? |