将下列程序补充完整,不能修改主函数的内容,使得程序的输出结果为 姓名: 王华 工号: 201107

将下列程序补充完整,不能修改主函数的内容,使得程序的输出结果为姓名:王华工号:201107#include<iostream>#include<string>usingn... 将下列程序补充完整,不能修改主函数的内容,使得程序的输出结果为
姓名: 王华
工号: 201107#include<iostream>
#include<string>
using namespace std;
class Person
{
private:
​string name;
public:
​Person(string name);
​void show();
};
class Employee:public Person
{
private:
​string eno;
public:
​Employee(string eno);
​void show();
};
class Teacher:public Employee
{
private:
​string degree;
public:
​Teacher(string degree);
​void show();
};
Person::Person(string name)
{
​this->name = name;
}
void Person::show()
{
​cout << "姓名: " << name << endl;
}
void Employee::show()
{
​cout << "工号: " << eno << endl;
}
void Teacher::show()
{
​cout << "学历: " << degree << endl;
}

int main()
{
​Teacher tea("王华", "20110754", "doctor");
​tea.show();
​return 0;
}
展开
 我来答
Ma_se
2018-05-06 · TA获得超过328个赞
知道小有建树答主
回答量:403
采纳率:75%
帮助的人:103万
展开全部
#include <iostream>#include <string>using namespace std; 
class Person{private:
string name;public:
Person(){};
Person(string); void show();
};
 
Person::Person(string name):name(name){} 
void Person::show(){
cout<<"姓名:"<<this->name<<endl;

class Employee:public Person{private:
string eno;public:
Employee(){};
Employee(string); void show();
};
Employee::Employee(string eno):eno(eno){}void Employee::show(){
cout<<"工号:"<<this->eno<<endl;

class Teacher:public Employee,Person{private:
string degree;public:
Teacher(){};
Teacher(string,string,string); void show();
};
Teacher::Teacher(string name,string eno,string degree):degree(degree){
Person(name).show();
Employee(eno).show();
}void Teacher::show(){
cout<<"学历:"<<this->degree<<endl;

int main(){
Teacher tea("abcdef","12345","doctor");
tea.show();
return 0;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式