<pre name="code" class="cpp">/*。
*Copyright(c)2014,煙臺大學計算機學院
*All right reserved,
*文件名:test.cpp
*作者:畢玉堂
*完成日期:2015年5月31日
*版本號:v1.0
*
問題描述:
*輸入描述:
*程序輸出:
*/
#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
Teacher(string n,int a,string s,string add,string t,string tit);
void display();
protected:
string name;
int age;
string sex;
string adds;
string phone;
string title;
};
Teacher::Teacher(string n,int a,string s,string add,string t,string tit)
{
name=n;
age=a;
sex=s;
adds=add;
phone=t;
title=tit;
}
void Teacher::display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"adds:"<<adds<<endl;
cout<<"telephone:"<<phone<<endl;
cout<<"title:"<<title<<endl;
}
class Cadre
{
public:
Cadre(string n,int a,string s,string add,string t,string p);
void display();
protected:
string name;
int age;
string sex;
string adds;
string phone;
string post;
};
Cadre::Cadre(string n,int a,string s,string add,string t,string p)
{
name=n;
age=a;
sex=s;
adds=add;
phone=t;
post=p;
}
void Cadre::display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"adds:"<<adds<<endl;
cout<<"phone:"<<phone<<endl;
cout<<"post:"<<post<<endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string n,int a,string s,string add,string t,string p,string tit,double w);
void show();
protected:
double wages;
};
Teacher_Cadre::Teacher_Cadre(string n,int a,string s,string add,string t,string p,string tit,double w):Teacher(n,a,s,add,t,tit),Cadre(n,a,s,add,t,p)
{
wages=w;
}
void Teacher_Cadre::show()
{
Teacher::display();
cout<<"post:"<<post<<endl;
cout<<"wages:"<<wages<<endl;
}
int main()
{
Teacher_Cadre te_ca("Wang-li",50,"women","135 Beijing Road,Shanghai","(021)61234567","prof","president",1534.5);
te_ca.show( );
return 0;
}
第12周項目1-教師兼幹部類
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.