#include<iostream>
#include<string>
using namespace std;
class base{
public:
base(string name1,string age1)
{name=name1;
age=age1;
}
void print()
{cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
}
private:
string name;
string age;
};
class leader:virtual public base{
public:
leader(string name1,string age1,string prof1,string dept1):
base(name1,age1)
{prof=prof1;
dept=dept1;
}
void print()
{base::print();
cout<<"职务:"<<prof<<endl;
cout<<"部门:"<<dept<<endl;
}
private:
string prof;
string dept;
};
class engieer:virtual public base{
public:
engieer(string name1,string age1,string work1,string profe1):
base(name1,age1)
{work=work1;
profe=profe1;
}
void print()
{base::print();
cout<<"职称:"<<work<<endl;
cout<<"专业:"<<profe<<endl;
}
private:
string work;
string profe;
};
class chairman:public leader,public engieer{
public:
chairman(string name1,string age1,string prof1,string dept1,string work1,string profe1):
base(name1,age1),leader(name1,age1,prof1,dept1),engieer(name1,age1,work1,profe1)
{ work=work1;
profe=profe1;}
void print()
{leader::print();
cout<<"职称:"<<work<<endl;
cout<<"专业:"<<profe<<endl;}
private:
string work;
string profe;
};
int main()
{ leader leader1("Mr.lin","38","财务主管","财务部");
leader1.print();
engieer engieer1("Mr.li","28","IT工程师","IT");
engieer1.print();
chairman chairman1("Mr.ma","38","IT部主任","IT部","主任","IT");
chairman1.print();
return 0;
}
#include<string>
using namespace std;
class base{
public:
base(string name1,string age1)
{name=name1;
age=age1;
}
void print()
{cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
}
private:
string name;
string age;
};
class leader:virtual public base{
public:
leader(string name1,string age1,string prof1,string dept1):
base(name1,age1)
{prof=prof1;
dept=dept1;
}
void print()
{base::print();
cout<<"职务:"<<prof<<endl;
cout<<"部门:"<<dept<<endl;
}
private:
string prof;
string dept;
};
class engieer:virtual public base{
public:
engieer(string name1,string age1,string work1,string profe1):
base(name1,age1)
{work=work1;
profe=profe1;
}
void print()
{base::print();
cout<<"职称:"<<work<<endl;
cout<<"专业:"<<profe<<endl;
}
private:
string work;
string profe;
};
class chairman:public leader,public engieer{
public:
chairman(string name1,string age1,string prof1,string dept1,string work1,string profe1):
base(name1,age1),leader(name1,age1,prof1,dept1),engieer(name1,age1,work1,profe1)
{ work=work1;
profe=profe1;}
void print()
{leader::print();
cout<<"职称:"<<work<<endl;
cout<<"专业:"<<profe<<endl;}
private:
string work;
string profe;
};
int main()
{ leader leader1("Mr.lin","38","财务主管","财务部");
leader1.print();
engieer engieer1("Mr.li","28","IT工程师","IT");
engieer1.print();
chairman chairman1("Mr.ma","38","IT部主任","IT部","主任","IT");
chairman1.print();
return 0;
}