5.19

#include<iostream>
#include<string>
using namespace std;
class base{
private:
	string name;
	int age;
public:
	base(string name1,int age1)
	{
		name=name1;age=age1;
	}
	void show()
	{
		cout<<"姓名:"<<name<<endl;
		cout<<"年龄:"<<age<<endl;
	}
};
class leader: public base{
private:
	string zw;
	string bm;
public:
	leader(string name1,int age1,string zw1,string bm1):base(name1,age1)
	{
		zw=zw1;bm=bm1;
	}
	void lshow()
	{
		base::show();
		cout<<"职位:"<<zw<<endl;
		cout<<"部门:"<<bm<<endl;
	}
};
class engieer: public base{
private:
	string zc;
	string zy;
public:
	engieer(string name1,int age1,string zc1,string zy1):base(name1,age1)
	{
		zc=zc1,zy=zy1;
	}
	void eshow1()
	{
		base::show();
		cout<<"职称:"<<zc<<endl;
		cout<<"专业:"<<zy<<endl;
	}
	void eshow2()
	{
		cout<<"职称:"<<zc<<endl;
		cout<<"专业:"<<zy<<endl;
	}
};
class chairman: public leader, public engieer{
public:
	chairman(string name1,int age1,string zw1,string bm1,string zc1,string zy1):leader(name1,age1,zw1,bm1),engieer(name1,age1,zc1,zy1)
	{}
	void cshow()
	{
        leader::lshow();
		engieer::eshow2();
	}
};
int  main()
{
	chairman ch("a",18,"b","c","d","e");
	ch.lshow();
	cout<<"--------------------"<<endl;
	ch.eshow1();
	cout<<"--------------------"<<endl;
	ch.cshow();
	cout<<"--------------------"<<endl;
	system("pause");
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值