#include <iostream>
using namespace std;
class A
{
public:
A(){AC();}
virtual ~A(){AD();}
virtual void AC(){cout<<"AC"<<endl;}
virtual void AD(){cout<<"AD"<<endl;}
};
class B:public A
{
public:
B(){BC();}
~B(){BD();}
void BC(){cout<<"BC"<<endl;}
void BD(){cout<<"BD"<<endl;}
};
int main()
{
A *p = new B;
delete p;
cout<<endl;
B *q = new B;
delete q;
system("pause");
return 0;
}
结果:
AC
BC
BD
AD
AC
BC
BD
AD
请按任意键继续. . .