*/
* Copyright (c) 2016,烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名:text.cpp
* 作者:常轩
* 微信公众号:Worldhello
* 完成日期:2016年5月8日
* 版本号:V1.0
* 问题描述:根据类图,写出程序
* 程序输入:无
* 程序输出:见运行结果
*/
#include<string>
#include <iostream>
using namespace std;
class Teacher
{
public:
Teacher(string nam,int a,char s,string tit,string ad,string t);
void display();
protected:
string name;
int age;
char sex;
string title;
string addr;
string tel;
}; Teacher::Teacher(string nam,int a,char s,string tit,string ad,string t):
name(nam),age(a),sex(s),title(tit),addr(ad),tel(t) { } void Teacher::display()
{
cout<<"name:"<<name<<endl;
cout<<"age"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"title:"<<title<<endl;
cout<<"address:"<<addr<<endl;
cout<<"tel:"<<tel<<endl;
} class Cadre
{
public:
Cadre(string nam,int a,char s,string p,string ad,string t);
void display();
protected:
string name;
int age;
char sex;
string post;
string addr;
string tel;
}; Cadre::Cadre(string nam,int a,char s,string p,string ad,string t):
name(nam),age(a),sex(s),post(p),addr(ad),tel(t) {} void Cadre::display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"post:"<<post<<endl;
cout<<"address:"<<addr<<endl;
cout<<"tel:"<<tel<<endl;
} class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string nam,int a,char s,string tit,string p,string ad,string t,float w);
void show( );
private:
float wage;
}; Teacher_Cadre::Teacher_Cadre(string nam,int a,char s,string t,string p,string ad,string tel,float w):
Teacher(nam,a,s,t,ad,tel),Cadre(nam,a,s,p,ad,tel),wage(w) {} void Teacher_Cadre::show( )
{
Teacher::display();
cout<<"post:"<<Cadre::post<<endl;
cout<<"wages:"<<wage<<endl;
} int main( )
{
Teacher_Cadre te_ca("Wang-li",50,'f',"prof.","president","135 Beijing Road,Shanghai","(021)61234567",1534.5);
te_ca.show( );
return 0;
}

运行结果:

C++走向远洋——46(教师兼干部类、多重继承、派生)的更多相关文章

  1. 第十二周项目一 教师兼干部类】 共建虚基类person

    项目1 - 教师兼干部类]分别定义Teacher(教师)类和Cadre(干部)类,采用多重继承方式由这两个类派生出新类Teacher_Cadre(教师兼干部).要求: (1)在两个基类中都包含姓名.年 ...

  2. C++走向远洋——68(十六周、文件)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  3. C++走向远洋——67(项目二、洗牌)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  4. C++走向远洋——66(十五周阅读程序)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  5. C++走向远洋——65(十五周、项目一)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  6. C++走向远洋——64(项目三、数组类模板)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  7. C++走向远洋——63(项目二2、两个成员的类模板)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  8. C++走向远洋——62(项目二1、类模板)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  9. C++走向远洋——61(项目一、排序函数模板)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

随机推荐

  1. Android如何制作自己的依赖库上传至github供别人下载使用

    Android如何制作自己的依赖库上传至github供别人下载使用 https://blog.csdn.net/xuchao_blog/article/details/62893851

  2. 搭建公司的React开发环境

    记录公司环境搭建 1.安装VSCODE, 安装网上的推荐各种控件2.安装node, yarn, 会自动添加path3.先初始化npm 全部按回车默认. npm init.  初始化yarn: yarn ...

  3. java数据库执行迁移报错Error creating bean with name 'flywayInitializer' defined in class path resource

    报错原因 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayI ...

  4. mybatis: Invalid bound statement (not found)即使调试源码也很难注意的坑

    需要改成 注意: 这个是不能一次性建立多级目录的 这个才是ok的

  5. 吴裕雄--天生自然 JAVA开发学习:网络编程

    import java.net.*; import java.io.*; public class GreetingClient { public static void main(String [] ...

  6. E - Apple Tree(树状数组+DFS序)

    There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. ...

  7. JS如何按时间粒度获取date的时间差

    获取date类型 var type = _xAxis[0].split(/-|:|\s/).length; 按时间粒度获取date的时间差 function getDateDiffByType(new ...

  8. HttpClient系统日志配置

    详细介绍在:http://hc.apache.org/httpclient-3.x/logging.html 一般使用context logging基本够用,context logging解释原文如下 ...

  9. h-index|IF|Good story|IPS

    科研论文写作 科研论文写作的关键在于写出研究的重要性. 对科研工作者的评价标准主要以论文为主,可以从论文的定性和定量角度评价.论文的外部评价,包括科学院分区(包括123类):影响因子IF,可以通过we ...

  10. 跨越真实和虚拟世界的边界——走近SIGGRAPH 2014大会

    2014大会" title="跨越真实和虚拟世界的边界--走近SIGGRAPH 2014大会"> 作者:孙鑫 微软亚洲研究院研究员 一场大会振奋一座城 温哥华位于加 ...