第十周实验报告2

来源:互联网 发布:一个hdmi网络传输器 编辑:程序博客网 时间:2024/06/03 20:20
#include <iostream>#include <string>using namespace std;class Teacher{public:Teacher( string nam, int ag, char s, string addr, string tel, string ti);void display();~Teacher(){}private:string name;int age;char sex;string address;string tel;string title;};class Cadre{public:Cadre( string nam, int ag, char s, string addr, string tel, string po);void display1();~Cadre(){}protected:string name;int age;char sex;string address;string tel;string post;};class Teacher_Cadre: public Teacher, public Cadre {public:Teacher_Cadre( string nam, int ag, char s, string addr, string tel, string ti, string po, int w):Teacher( nam, ag, s, addr, tel, ti),Cadre( nam, ag, s, addr, tel, po){ wages = w;}void show();~Teacher_Cadre(){}private:int wages;};         Teacher::Teacher( string nam, int ag, char s, string addr, string te, string ti){name = nam;age = ag;sex = s;address = addr;    tel = te;title = ti;}void Teacher::display(){cout << "name: " << name << endl;    cout << "tellphone: " << tel << endl;cout << "sex: " << sex << endl;cout << "age: " << age << endl;cout << "address: " << address << endl;cout << "title: " << title <<endl;}Cadre::Cadre( string nam, int ag, char s, string addr, string te, string po){name = nam;age = ag;sex = s;address = addr;    tel = te;post = po;}void Cadre::display1(){cout << "name: " << name << endl;    cout << "tellphone: " << tel << endl;cout << "sex: " << sex << endl;cout << "age: " << age << endl;cout << "address: " << address << endl;cout << "post: " << post <<endl;}void Teacher_Cadre::show(){Teacher::display ();cout << "post: " << post <<endl;cout << "wages: " << wages << endl;}int main(){Teacher_Cadre tc("Wang-li",19,'f',"115 Beijing Road,Shanghai", "12345678902", "teacher", "ksjdbh", 9999);tc.show();system("pause");return 0;}


 

 

 

name: Wang-li
tellphone: 12345678902
sex: f
age: 19
address: 115 Beijing Road,Shanghai
title: teacher
post: ksjdbh
wages: 9999
请按任意键继续. . .

 

 

原创粉丝点击