摘要:
析构函数在下边3种情况时被调用: 1.对象生命周期结束,被销毁时; 2.delete指向对象的指针时,或delete指向对象的基类类型指针,而其基类虚构函数是虚函数时; 3.对象i是对象o的成员,o的析构函数被调用时,对象i的析构函数也被调用。情况1请看下边代码:#include class A { public: A() { coutclass A { public: A() { cout class A { public: A() { cout<<"constructing A"<<endl; } ~A() { cout<<" 阅读全文