自考新教材-p271_1

源程序:

#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;
}

运行结果:

 

posted @ 2020-02-04 21:48  bobo哥  阅读(147)  评论(0编辑  收藏  举报