#include <iostream> #include <string> using namespace std; class Teacher { public: Teacher(string, int, char, string, int, string); void display(); protected: string name; int age; char sex; string addr; int tel; string title; }; Teacher::Teacher(string nam, int a, char s, string ad, int te, string tit) { name=nam; age=a; sex=s; addr=ad; tel=te; title=tit; } 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, int, char, string, int, string); void display1(); protected: string name; int age; char sex; string addr; int tel; string post; }; Cadre::Cadre(string nam, int a, char s, string ad, int te, string po) { name=nam; age=a; sex=s; addr=ad; tel=te; post=po; } void Cadre::display1() { cout<<"name: "<<name<<endl; cout<<"age: "<<age<<endl; cout<<"sex: "<<sex<<endl; cout<<"address: "<<addr<<endl; cout<<"tel: "<<tel<<endl; cout<<"post: "<<post<<endl; } class Teacher_Cadre: public Teacher, public Cadre { public: Teacher_Cadre::Teacher_Cadre(string nam, int a, char s, string ad, int te, string tit, string po, double w): Teacher(nam, a, s, ad, te, tit), Cadre(nam, a, s, ad, te, po), wage(w){} void show(); private: double wage; }; void Teacher_Cadre::show() { Teacher::display(); cout<<"post: "<<Cadre::post<<endl; cout<<"wage: "<<wage<<endl; }; int main() { Teacher_Cadre person("ZhangLei", 23, 'M', "Beijing", 87891611, "professor", "assitant", 8981.4); person.show(); system("pause"); return 0; } 给这串代码做个流程图
最新发布