#include <iostream.h>
class A
{
public:
A()
{ cout<<"A constructor called!"<<endl; }
void f(){ cout<<"f() is called in A!"<<endl; }
};
class B :public A
{
public:
B(){ cout<<"B constructor called!"<<endl; }
virtual void f(){ cout<<"f() is called in B!"<<endl; }
};
class C:public B
{
public:
C(){cout<<"C constructor called!"<<endl;}
void f(){cout<<"f() is called in C!"<<endl;}
};
void main()
{
A * pa;
B * pb;
pa = pb = new C;
pa->f();
pb->f();
}
絮絮念秋风