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.
35 lines
438 B
35 lines
438 B
#include <iostream>
|
|
#include <string>
|
|
#include <memory>
|
|
using std::cin, std::cout, std::string;
|
|
|
|
class A
|
|
{
|
|
public:
|
|
A() { cout << "A构造\n"; }
|
|
~A() { cout << "A析构\n"; }
|
|
};
|
|
|
|
class Test
|
|
{
|
|
std::unique_ptr<A[]> p;
|
|
|
|
public:
|
|
Test()
|
|
{
|
|
p = std::make_unique<A[]>(3);
|
|
throw -1;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
try
|
|
{
|
|
Test t;
|
|
}
|
|
catch (int)
|
|
{
|
|
cout << "捕获了 int异常\n";
|
|
}
|
|
} |