隐藏代码简示

版权声明:原创作品请注明出处: Ma_Hong_Kai CSDN https://blog.csdn.net/Ma_Hong_Kai/article/details/87081000

覆盖、隐藏、重载

//#include "pch.h"
#include <iostream>
using namespace std;

class A
{
public:
	void base()
	{
		cout << "base A" << endl;
	}
};
class B :public A
{
public :
	void base()
	{
		cout << "base B" << endl;
	}
};
int main()
{
	A a;
	B b;
	a.base();
	b.base();

	A *p1 = new A;
	B *p2 = new B;
	p1->base();
	p2->base();

	system("pause");
}

输出:

base A
base B
base A
base B
请按任意键继续.

展开阅读全文

没有更多推荐了,返回首页