#include<stdio.h> class A{ public: A(){ p(); } virtual void p(){ printf("A"); } virtual ~A(){ p(); } }; class B:public A{ public: B(){ p(); } void p(){ printf("B"); } ~B(){ p(); } }; int main(int, char**){ A* a = new B(); delete a; }
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题