作业5.19

参照书本150页例5.13

#include<iostream>
#include<string>
using namespace std;
class base{
public:
	base(string i,int j)
	{
		name=i;
		age=j;
	}
    void show()
	{
		cout<<"姓名:"<<name<<endl;
		cout<<"年龄:"<<age<<endl;
	}
private:
	string name;
	int age;
};
class leader: virtual public base{
public:
	leader(string i,int j,string k,string l):base(i,j){
		post=k;
		dept=l;
	}
	void show()
	{
		base::show();
		cout<<"职务:"<<post<<endl;
		cout<<"部门:"<<dept<<endl;
	}
private:
	string post;
	string dept;
};
class engieer:virtual public base{
public:
	engieer(string i,int j,string a,string b):base(i,j)
	{
		title=a;
		major=b;
	}
	void show()
	{
		base::show();
		cout<<"职称:"<<title<<endl;
		cout<<"专业:"<<major<<endl;
	}
private:
	string title;
	string major;
};
class chairman:public leader,public engieer{
public:
	chairman(string i,int j,string k,string l,string a,string b):base(i,j),leader(i,j,k,l),engieer(i,j,a,b)
	{
		cout<<"主任工程师"<<endl;
		base::show();
		cout<<"职务:"<<i<<endl;
		cout<<"部门:"<<j<<endl;
		cout<<"职称:"<<a<<endl;
		cout<<"专业:"<<b<<endl;
	}
};
int main()
{
	base b("华庆",22);
	b.show();
	cout<<"----------------------------"<<endl;
	leader lea("鹿仁杰",19,"主任","管理部");
	lea.show();
	cout<<"----------------------------"<<endl;
	engieer eng("鲁任矣",24,"网络工程师","计算机专业");
	eng.show();
	cout<<"----------------------------"<<endl;
	chairman cha1("波仕",40,"主任","管理部","工程师","管理专业");
	system("pause");
	return 0;
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值