/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:
* 作 者: 张传新
* 完成日期: 2012 年 05 月 08 日
* 版 本 号: 1.0
* 对任务及求解方法的描述部分
* 输入描述:
* 问题描述:
* 程序输出:
* 程序头部的注释结束
*/
#include<iostream>
#include<string>
using namespace std;
class Teacher//定义Teacher类
{
public:
void display();
Teacher(string n, int a, char s, string d, int m, string t)
{
name = n;
age = a;
sex = s;
addr = d;
num = m;
title = t;
}
protected:
string name;
int age;
char sex;
string addr;
int num;
string title;
};
class Cadre//定义Cadre类
{
public:
void display();
Cadre(string n, int a, char s, string d, int m, string p)
{
name = n;
age = a;
sex = s;
addr = d;
num = m;
post = p;
}
protected:
string name;
int age;
char sex;
string addr;
int num;
string post;
};
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string n, int a, char s, string d, int m, string t,string p, float w)
:Teacher(n,a,s,d,m,t),Cadre(n,a,s,d,m,p),wages(w){}
void show();
protected:
float wages;
};
void Teacher::display()
{
cout << "name:" << name << endl;
cout << "age:" << age << endl;
cout << "sex:" << sex << endl;
cout << "addr:" << addr << endl;
cout << "num:" << num << endl;
cout << "title:" << title << endl;
}
void Cadre::display()
{
cout << "name:" << name << endl;
cout << "age:" << age << endl;
cout << "sex:" << sex << endl;
cout << "addr:" << addr << endl;
cout << "num:" << num << endl;
cout << "post:" << post << endl;
}
void Teacher_Cadre::show()
{
Teacher::display();
cout << "post:" << post << endl;
cout << "wages:" << wages << endl;
}
int main()
{
Teacher Teacher1("小王", 20, 'f', "烟台大学", 110, "老师");
Cadre Cadre1("小野", 19, 'm', "烟台大学", 119, "指导");
Teacher_Cadre Teacher_Cadre1("小张", 20, 'f', "烟台大学", 120, "老师","指导", 18888);
Teacher1.display();
cout << endl;
Cadre1.display();
cout << endl;
Teacher_Cadre1.show();
cout << endl;
system("pause");
return 0;
}
运行结果:
name:小王
age:20
sex:f
addr:烟台大学
num:110
title:老师
name:小野
age:19
sex:m
addr:烟台大学
num:119
post:指导
name:小张
age:20
sex:f
addr:烟台大学
num:120
title:老师
post:指导
wages:18888
请按任意键继续. . .
体会:
不容易啊~~~~但把五一放假忘的东西捡起来不少,明天接着奋斗!!!