小白求助 关于异常的问题
#include "iostream"using std::endl;
using std::cout;
using std::cin;
class Test
{
private:
int a;
int b;
public:
Test(int a, int b)
{
this->a = a;
this->b = b;
}
~Test()
{
cout << "析构函数执行了\n";
}
};
void objPlay()
{
Test t1(11, 22);
Test t2(33, 44);
cout << "准备抛异常\n";
throw;//如图 直接抛异常显示错误
}
void main()
{
try
{
objPlay();
}
catch (...)
{
cout << "未知类型异常\n";
}
system("pause");
} 顶
页:
[1]