- 01./* (程序头部注释开始)
- 02.* 程序的版权和版本声明部分
- 03.* Copyright (c) 2011, 烟台大学计算机学院学生
- 04.* All rights reserved.
- 05.* 文件名称:
- 06.* 作 者: zhang lu
- 07.* 完成日期: 2012 年
09.* 记录: 10.*对任务及求解方法的描述部分 11.* 输入描述: 12.* 问题描述:实现分数类中的<<和>>运算符重载,实现分数的输入和输出 13.1* 程序头部的注释结束 14.*/ 15.#include <iostream> 16.#include <string> 17.using namespace std; 18.class Teacther 19.{ 20.public: 21. Teacther(string t,string nam,int n, char m,string p,string s):title(t),name(nam),age(n),sex(m),place(p),phone(s){} 22. void display(); 23. 24.protected: 25. string title; 26. string name; 27. int age; 28. char sex; 29. string place; 30. string phone; 31.}; 32.void Teacther::display() 33.{ 34. 35. cout<<"姓名:"<<name<<endl; 36. cout<<"年龄:"<<age<<endl; 37. cout<<"性别:"<<sex<<endl; 38. cout<<"住址:"<<place<<endl; 39. cout<<"电话:"<<phone<<endl; 40. cout<<"职称:"<<title<<endl; 41.} 42.class Cadre 43.{ 44.public: 45. Cadre(string a,string b,int c,char d,string e,int f,string h):title(a),name(b),age(c),sex(d),place(e),phone(f),post(h){} 46. 47.protected: 48. string title; 49. string name; 50. int age; 51. char sex; 52. string place; 53. int phone; 54. string post; 55.}; 56.class Teacther_Cadre:public Teacther,public Cadre 57.{ 58.public: 59. Teacther_Cadre(string t,string nam,int n, char m,string p,string s,string a,string b,int c,char d,string e,int f,string h,int q):Teacther(t,nam,n,m,p,s),Cadre(a,b,c,d,e,f,h){wages=q;} 60. void show(); 61. 62. int wages; 63.}; 64.void Teacther_Cadre::show() 65.{ 66. display(); 67. cout<<"职务:"<<post<<endl; 68. cout<<"工资:"<<wages<<endl; 69.} 70.void main() 71.{ 72. Teacther_Cadre t("jiaoshou","zhanglu", 22,'f',"ji ning","18253591061","jiaoshou", "zhanglu", 22,'f'," lingyi",18253591061,"jiaoshi",20000); 73. t.show(); 74. system("pause"); 75.}
- 08.* 版 本 号:
实验报告 12-2
最新推荐文章于 2023-09-21 10:45:45 发布