问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#include<iostream>
#include<string>
using namespace std;
class Teacher
{
public:
Teacher( string name, string sex, string phone, string add,string title, int year) :name(name), sex(sex), phone(phone), add(add), title(title), year(year){}
void show()
{
cout << "name" << name << endl;
cout << "sex" << sex << endl;
cout << "year" << year << endl;
cout << "phone" << phone << endl;
cout << "add" << add << endl;
cout << "title" << title << endl;
}
protected:
string name, sex, phone, add, title; int year;
};
class cadre
{
public:
cadre(string post, string name, string sex, string phone, string add, int year) :name(name), sex(sex), phone(phone), add(add), post(post), year(year) {}
void show()
{
cout << "name" << name << endl;
cout << "sex" << sex << endl;
cout << "year" << year << endl;
cout << "phone" << phone << endl;
cout << "add" << add << endl;
cout << "post" << post << endl;
}
protected:
string name, phone, sex, add, post; int year;
};
class Teacher_cadre :public Teacher, public cadre
{
public:
Teacher_cadre( string name, string sex, string phone, string add, string title, int year, string post, float wage)
:Teacher(name, sex, phone, add, title ,year), cadre(name, sex, phone, add, post ,year ), wage(wage) {}
void dispaly()
{
Teacher::show();
cout << post << post << endl;
cout << wage << wage << endl;
}
private:
float wage;
};
int main()
{
Teacher_cadre obj("张三","男", 35,"1234561111", "重庆永川", "教授", "院长", 8000);
obj.Teacher::show();
obj.dispaly();
return 0;
}