#include<iostream> #include<string> using namespace std; class Teacher { public: Teacher(string na, int a, char s, string ad, int te, string t) :name(na), age(a), sex(s), address(ad), tell(te), title(t) { } void display(); protected: string name; int age; char sex; string address; int tell; string title; }; void Teacher::display() { cout << "name=" << name << endl; cout << "age=" << age << endl; cout << "sex=" << sex << endl; cout << "address=" << address << endl; cout << "tell=" << tell << endl; cout << "title=" << title << endl; } class Grade { public: Grade(string na, int a, char s, string ad, int te, string p) { name1 = na; age1 = a; sex1 = s; address1 = ad; tell1 = te; post = p; } void display1(); protected: string name1; int age1; char sex1; string address1; int tell1; string post; }; void Grade::display1() { cout << "name=" << name1 << endl; cout << "age=" << age1 << endl; cout << "sex=" << sex1 << endl; cout << "address=" << address1 << endl; cout << "tell=" << tell1 << endl; cout << "post=" << post << endl; } class Teacher_Grade :public Teacher, public Grade { public: Teacher_Grade(string na, int a, char s, string ad, int te, string t, string p, float w) :Teacher(na, a, s, ad, te, t), Grade(na, a, s, ad, te, p), wage(w) { } void show(); private: float wage; }; void Teacher_Grade::show() { cout << "name=" << name1 << endl; cout << "age=" << age1 << endl; cout << "sex=" << sex1 << endl; cout << "address=" << address1 << endl; cout << "tell=" << tell1 << endl; cout << "post=" << post << endl; cout << "title=" << title << endl; cout << "wage=" << wage << endl; } int main() { Teacher_Grade tg1("qcy", 22, 'n', "nt", 123, "ilove", "zwj", 2.3); tg1.show(); return 0; }