1 #include <iostream> 2 using namespace std; 3 class A 4 { 5 public: 6 A() { } 7 virtual ~A() { cout << "destructor A" << endl; } 8 }; 9 class B:public A { 10 public: 11 ~B() { cout << "destructor B" << endl; } 12 }; 13 int main() 14 { 15 A * pa; 16 pa = new B; 17 delete pa; 18 return 0; 19 }