#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
//栈解旋:进入try后在栈构造的对象都会自动析构,与构造顺序相反
class Person
{
public:
int a;
public:
Person(int a)
{
this->a = a;
cout<<"有参构造="<<a<<endl;
}
~Person()
{
cout<<"析构"<<a<<endl;
}
};
int main()
{
try
{
Person ob1(10);
Person ob2(20);
Person ob3(30);
throw 0;
}
catch (int ex)
{
cout<<"asdfasd"<<endl;
}
}
栈解旋
最新推荐文章于 2023-11-30 20:45:00 发布