对象死亡的时候会调用析构函数
#include<iostream>
using namespace std;
class MM
{
public:
~MM()
{
cout << "调用析构函数" << endl << endl;
}
};
int main()
{
{
MM mm;
//动态申请的内存需要手动释放
MM* p = new MM();
cout << "1........" << endl;
delete p;
cout << "2........" << endl;
p = nullptr;
}
cout << "对象死亡" << endl;
return 0;
}