#include<iostream>
#include<string>
using namespace std;
class base{
public:
base(string n,int a)
{
name=n;
age=a;
}
void print()
{
cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
}
private:
string name;
int age;
};
class leader:virtual public base{
public:
leader(string n,int a,string m,string d):
base(n,a)
{
major=m;
department=d;
}
void print()
{
base::print();
cout<<"职务:"<<major<<endl;
cout<<"部门:"<<department<<endl;
}
private:
string major;
string department;
};
class engineer:virtual public base{
public:
engineer(string n,int a,string j,string i):
base(n,a)
{
job=j;
major_in=i;
}
void print()
{
cout<<"职称:"<<job<<endl;
cout<<"专业:"<<major_in<<endl;
}
private:
string job;
string major_in;
};
class chairman:public leader,public engineer{
public:
chairman(string n,int a,string m,string d,string j,string i):
base(n,a),leader(n,a,m,d),engineer(n,a,j,i)
{
cout<<"主任工程师类信息测试:"<<endl;
}
void print()
{
leader::print();
engineer::print();
}
};
int main()
{
chairman man1("wu",20,"经理","编辑部","编程师","信管");
man1.print();
system("pause");
return 0;
}
08-16
08-16
08-23