You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
432 B
38 lines
432 B
#include <iostream>
|
|
#include <string>
|
|
using std::cin, std::cout, std::string;
|
|
|
|
class A
|
|
{
|
|
public:
|
|
A() { cout << "A构造\n"; }
|
|
~A() { cout << "A析构\n"; }
|
|
};
|
|
|
|
class Test
|
|
{
|
|
A *p;
|
|
|
|
public:
|
|
Test()
|
|
{
|
|
p = new A[3];
|
|
throw -1;
|
|
}
|
|
~Test()
|
|
{
|
|
delete[] p;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
try
|
|
{
|
|
Test t{};
|
|
}
|
|
catch (int)
|
|
{
|
|
cout << "捕获了 int异常\n";
|
|
}
|
|
} |