第12周实验报告2
来源:互联网 发布:python数据采集 pdf 编辑:程序博客网 时间:2024/05/18 13:28
实验目的:多重继承
* 程序头部注释开始
* 程序的版权和版本声明部分
* 烟台大学计算机学院学生
* 文件名称:
* 作
* 完成日期:
* 版本号:
#include <iostream>#include<string>using namespace std;class Teacher{ public: Teacher(string nam,int a ,char s,string ad, int te,string t) { name = nam; age = a; sex = s; add = ad; tel = te; title = t; } ~Teacher(){}; void display(); protected: string name; int age; char sex; string add; int tel; string title;};class Cadre{ public: Cadre(string nam,int a ,char s,string ad, int te,string p) { name = nam; age = a; sex = s; add = ad; tel = te; post = p; } ~Cadre(){}; protected: string name; int age; char sex; string add; int tel; string post;};class Teacher_Cadre:public Teacher,public Cadre{ public: Teacher_Cadre(string nam,int a ,char s,string ad, int te,string t,string p,float w):Teacher(nam,a,s,ad,te,t),Cadre(nam,a,s,ad,te,p),wages(w){} void show(); private: float wages;};int main(){Teacher_Cadre T_C("hubin", 20, 'm', "yantaidaxue", 182531," tejijiaoshi"," gongwuyuan", 5000); T_C.show();system("pause"); return 0;}void Teacher::display(){cout<<"mane:"<<Teacher::name<<endl;cout<<"age:"<<Teacher::age<<endl;cout<<"sex:"<<Teacher::sex<<endl;cout<<"add:"<<Teacher::add<<endl;cout<<"tel:"<<Teacher::tel<<endl;cout<<"title:"<<Teacher::title<<endl;}void Teacher_Cadre::show(){Teacher::display();cout<<"post:";cout<<post<<endl;cout<<"wages:"<<wages<<endl;}
截图:
mane:hubinage:20sex:madd:yantaidaxuetel:182531title: tejijiaoshipost: gongwuyuanwages:5000请按任意键继续. . .
继承多了,虽然有点不适应,但功能还是挺大的。
- 第12周实验报告任务2
- 第12周实验报告2
- 第12周实验报告2
- 第12周实验报告2(修改版)
- 第12周实验报告求阶乘2-1
- 第12周实验报告3
- 第12周实验报告任务1
- 第12周实验报告3
- 第12周实验报告1
- 第12周实验报告4
- 第12周实验报告3
- 第12周实验报告3
- 第12周实验报告任务3
- 第12周实验报告任务3
- 第12周实验报告任务4
- 第12周实验报告4
- 第2周实验报告2
- 第13周实验报告2
- 文件读写的文本方式与二进制方式、文本文件与二进制文件之区别
- 被动的主动性
- (麻烦)Flip Game (CD1488)
- POJ 3157 And Then There Was One
- Quick Linux Server Installation
- 第12周实验报告2
- pthread_cond_timedwait实例代码
- c++ unio 学习总计
- 指针的赋值和内存访问
- Efficient C Tips #6 – Don’t use the ternary operator
- 素数筛选与快速幂取模
- 一道中兴笔试题
- “NETDEV WATCHDOG: eth0: transmit timed out” 后网卡当掉
- FIREFOX与IE兼容性探讨