#include <iostream>
using namespace std;
class A{ public: A(){cout<<"class A construtor"<<endl;} ~A(){cout<<"class A destrutor"<<endl;} void fun1(){cout<<"fun1()"<<endl;} }; int main() { A a; A a2=a; return 0; }
运行结果:
class A construtor
class A destrutor
class A destrutor
共调用2次析构函数,析构函数次数=构造函数次数+拷贝构造函数次数
标签:函数,函数调用,次数,析构,class,构造函数 From: https://www.cnblogs.com/cxacswx/p/17283844.html