关于继承

是什么:有个公共功能的基类。允许从基类中分离出来,从最初的父类中创建子类
目的:简化代码避免重复
写法:

class TIme :public Ent//time是Ent的超集
例子
class position
{
public:
	const int addres=1;
};
class Player:public position
{
public :
	int a;
	Player()
	{
		a = 0;
	}
};
int main()
{
	Player k;
	std::cout << k.addres << std::endl;
	std::cin.get();
}
posted @ 2024-07-08 14:53  Wzline  阅读(2)  评论(0编辑  收藏  举报