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;
}

 

posted on 2019-03-26 17:07  newbird2017  阅读(137)  评论(0编辑  收藏  举报