首页 > 代码库 > 第12周——教师干部类
第12周——教师干部类
#include <iostream>using namespace std;class Teacher{ public: Teacher(string nam,int ag,string add,string tel,string se,string ti): name(nam),age(ag),addr(add),telnum(tel),sex(se),title(ti){} protected: int age; string addr,sex,title,name,telnum;};class Cadre{ public: Cadre(string nam,int ag,string add,string tel,string se,string po): name(nam),age(ag),addr(add),telnum(tel),sex(se),post(po){} void display (); protected: int age; string addr,sex,name,telnum,post;};class Cadre_Teacher:public Teacher ,public Cadre{ public: Cadre_Teacher (string nam,int ag,string add,string tel,string se,string po,string ti,double w): Cadre(nam,ag,add,tel,se,po),Teacher(nam,ag,add,tel,se,ti),wages(w){} void show(); protected: double wages;};void Cadre::display(){ cout<<"name:"<<name<<endl; cout<<"age:"<<age<<endl; cout<<"tel:"<<telnum<<endl; cout<<"sex:"<<sex<<endl; cout<<"post:"<<post<<endl;}void Cadre_Teacher::show (){ Cadre::display(); cout<<"title:"<<title<<endl; cout<<"salary:"<<wages<<endl;}int main(){ Cadre_Teacher C1("shanhongyu",19,"YantaiUnversity","1886555XXXX","man","freshman","stu",100); C1.show(); return 0;}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。