class D:public C{ public: D(){cout << "D()" << endl;} virtual ~D(){ cout << "~D()"<<endl;} }; class E:public D{ public: E(){cout << "E()" << endl;} virtual ~E(){ cout << "~E()" << endl;} }; void test_3() { C*p = new D; delete p; } void test_4() { D*p = new E; delete p; } int main() { cout << "test 1" << endl; test_1(); cout << "test 2" << endl; test_2(); cout << "test 3" << endl; test_3(); cout << "test 4" << endl; test_4(); return 0; }