源程序:
#include <iostream>
using namespace std;
class A
{
public:
int i;
virtual void func()
{
cout << "A0" << endl;
}
virtual void func2()
{
cout << "A1" << endl;
}
virtual void func3()
{
cout << "A3" << endl;
}
};
class B :public A
{
int j;
void func()
{
cout << "B0" << endl;
}
void func3()
{
cout << "B3" << endl;
}
};
int main()
{
A *a;
B b;
a = &b;
a->func();
a->func3();
system("pause");
return 1;
}
运行结果: