#include <iostream>
#include <string>
using namespace std;
class person
{
string name; // 姓名
int age; // 年龄
public:
person() {}
void setname(string na)
{
name=na;
}
void setage(int a)
{
age=a;
}
string getname()
{
return name;
}
int getage()
{
return age;
}
};
class Teacher: public Person // (1)
{
string title;
public:
Teacher() { }
void settitle(string tie)
{
title=tie;
}
string gettitle()
{
return title;
}
};
class Cadre: public person // (2)
{
string post;
public:
Cadre () { }
void setpost(string pst)
{
post=pst;
}
string getpost()
{
return post;
}
};
class Teacher_Cadre: public Teacher,public Cadre
{
string wages;
public
Teacher_Cadre(){}
void setwages(string was)
{
wages=was;
}
string getwages()
{
return wages
}
};
class chairman: public Teacher_Cadre
{
} ;// (3)
int main()
{
chairman c;
c.setname("张三");
c.setage(42);
c.settitle("副教授");
c.setpost("主任");
c.setwages("1534.5");
cout <<c.getname() << " " <<c.getage()<<" 岁," <<c.gettie() <<c.getpst() <<endl;
cout <<c.getwages()<< endl;
return 0;
}
#include <string>
using namespace std;
class person
{
string name; // 姓名
int age; // 年龄
public:
person() {}
void setname(string na)
{
name=na;
}
void setage(int a)
{
age=a;
}
string getname()
{
return name;
}
int getage()
{
return age;
}
};
class Teacher: public Person // (1)
{
string title;
public:
Teacher() { }
void settitle(string tie)
{
title=tie;
}
string gettitle()
{
return title;
}
};
class Cadre: public person // (2)
{
string post;
public:
Cadre () { }
void setpost(string pst)
{
post=pst;
}
string getpost()
{
return post;
}
};
class Teacher_Cadre: public Teacher,public Cadre
{
string wages;
public
Teacher_Cadre(){}
void setwages(string was)
{
wages=was;
}
string getwages()
{
return wages
}
};
class chairman: public Teacher_Cadre
{
} ;// (3)
int main()
{
chairman c;
c.setname("张三");
c.setage(42);
c.settitle("副教授");
c.setpost("主任");
c.setwages("1534.5");
cout <<c.getname() << " " <<c.getage()<<" 岁," <<c.gettie() <<c.getpst() <<endl;
cout <<c.getwages()<< endl;
return 0;
}