#include <iostream>
using namespace std;
class A
{
public :
virtual ~A()
{
}
void create()
{
cout << "A::create()" << endl;
t_create();
}
virtual void t_create()
{
cout << "A::t_create()" << endl;
}
};
class B:public A
{
public:
virtual void t_create()
{
cout << "B::t_create()" << endl;
}
};
class C :public B
{
public:
virtual void t_create()
{
cout << "C::t_create()" << endl;
}
};
int main()
{
A *base = new C;
base->create();
return 0;
}
虚函数的简单用法
最新推荐文章于 2021-05-22 15:13:25 发布