#include <iostream> using namespace std; class A { public: virtual ~A(){cout<<"A destructor---"<<endl;} }; class B:public A { public: B(){cout<<"B----constructor---"<<endl;m_p=new char[10];} ~B(){cout<<"B destructor---"<<endl;} private: char *m_p; }; int main() { A *p=new B; delete p;//会调用子类对象的析构,防止子类对象申请内存不被释放,我在想他这个为什么会调用基类析构函数,既然是多态 getchar(); return 0; }