01./*
02.* 程序的版权和版本声明部分:
03.* Copyright (c) 2011, 烟台大学计算机学院
04.* All rights reserved.
05.* 文件名称:test.cpp
06.* 作 者:刘芳
07.* 完成日期:2014 年05 月17 日
08.* 版 本 号:v1.0
09.* 对任务及求解方法的描述部分:
10.* 输入描述:无
11.* 问题描述: 输入老师的姓名,年龄,性别,地址,电话号码,职称,职务等
12.* 程序输出:输出以上信息
13.* 问题分析:略
14.* 算法设计:略
15.*/
#include <iostream>
#include<cstring>
using namespace std;
class Teacher
{
public:
void display();
Teacher(string name1,int age1,string sex1,string add1,string num1,string title1);
protected:
string name;
int age;
string sex;
string add;
string num;
string title;
};
class Cadre
{
public:
void display();
Cadre(string name1,int age1,string sex1,string add1,string num1,string post1);
protected:
string name;
int age;
string sex;
string add;
string num;
string post;
};
class Teacher_Cader:public Teacher,public Cadre
{
public:
void show();
Teacher_Cader(string name1,int age1,string sex1,string add1,string num1,string title1,string post1,int salary1);
protected:
int salary;
};
Teacher::Teacher(string name1,int age1,string sex1,string add1,string num1,string title1)
{
name=name1;
age=age1;
sex=sex1;
add=add1;
num=num1;
title=title1;
}
Cadre::Cadre(string name1,int age1,string sex1,string add1,string num1,string post1)
{
name=name1;
age=age1;
sex=sex1;
add=add1;
num=num1;
post=post1;
}
Teacher_Cader::Teacher_Cader(string name1,int age1,string sex1,string add1,string num1,
string title1,string post1,int salary1):
Teacher(name1,age1,sex1,add1,num1,title1),
Cadre(name1,age1,sex1,add1,num1,post1),salary(salary1) {}
void Teacher::display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"add:"<<add<<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<<"add:"<<add<<endl;
cout<<"num:"<<num<<endl;
cout<<"post:"<<post<<endl;
}
void Teacher_Cader::show()
{
Teacher::display();
cout<<"post:"<<post<<endl;
cout<<"salary:"<<salary<<endl;
}
int main()
{
Teacher_Cader TC("依依",22,"女","青岛","123456","优秀教师","校长",10000);
TC.show();
return 0;
}