Teacher(教师类)和Cardre(干部类)的定义分别是什么?

2020-05-19 社会 133阅读
#include
#include
using namespace std;
class Person
{
public:
Person(string nam,int a,int nu)
{
name=nam;
age=a;
number=nu;
}
void display()
{
cout<<"name: "< cout<<"age: "< cout<<"number: "< }
protected:
string name;
int age;
int number;
};
class Teacher:public Person
{
public:
Teacher(string nam,int a,int nu,string t):Person(nam,a,nu),title(t){}
void show1()
{
display();
cout<<"title: "< }
protected:
string title;
};
class Cadre:public Person
{
public:
Cadre(string nam,int a,int nu,string p):Person(nam,a,nu),post(p){}
void show2()
{
display();
cout<<"post: "< }
protected:
string post;
};
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string nam,int a,int nu,string t,string p,float w):
Teacher(nam,a,nu,t),Cadre(nam,a,nu,p),wages(w){}
void show3()
{
show1();
cout<<"post: "< cout<<"wages: "< }
protected:
float wages;
};
int main()
{
Teacher_Cadre tc("harry",36,12345,"director","manager",100000);
tc.show3();
while(1);
return 0;
}
参考一下,这个程序差不多的。下面的继承是多重继承。
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com