#include<iostream>
using namespace std;
class A{
public:
virtual void fa(void){cout<<"A::fa1"<<endl;}
void fb(void){cout<<"A::fb2"<<endl;}
};
class B:public A{
public:
void fa(void){cout<<"B::fa1"<<endl;}
void fb(void){cout<<"B::fb2"<<endl;}
};
void main(){
A *pa=new A;
A *pb=new B;
pa->fa();
pb->fb();
pb->fa();
pb->A::fa();
((B*)pb)->fb();
}
测试程序