#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;
}
5.19
最新推荐文章于 2024-05-19 11:39:30 发布