第十周实验报告2

#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
请按任意键继续. . .

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值