c++的一段代码,编译器总是报错,求改正

#include<iostream>#include<string>usingnamespacestd;classPerson{protected:stringName;... #include <iostream>
#include <string>
using namespace std;
class Person{
protected:
string Name;
string Id;
public:
Person(string name,string id):Name(name),Id(id)
{

}
void show_Person()
{
cout<<"Name :"<<Name<<endl;
cout<<"Id :"<<Id<<endl;
}
};

class Employee:public virtual Person{
protected:
string Dept;
float Salary;
public:
Employee(string name,string id,string dept,float salary):Person(name,id)
{
Dept=Dept;
Salary=salary;
}
void show_Employee()
{
Person::show_Person();
cout<<"Dept :"<<Dept<<endl;
cout<<"Salary :"<<Salary<<endl;
}
};

/*class Student:public virtual Person{
protected:
string Major;
string Level;
public:
Student(string name,string id,string major,string level):Person(name,id)
{
Major=major;
Level=level;
}
void show_Student()
{
Person::show_Person();
cout<<"Major :"<<Major<<endl;
cout<<"Level :"<<Level<<endl;
}
};*/

class Teacher:public Employee{
protected:
string Title;
public:
Teacher(string title,string name,string id,string dept,float salary):Person(name,id),Employee(dept,salary),Title(title)
{

}
void show_Teacher()
{
Employee::show_Employee();
cout<<"Title :"<<Title<<endl;
}
};

/*class Assistant:public Employee,public Student{
public:
void show_Assistant()
{
Student::show_Student();
}
};*/
int main()
{
return 0;
}
编译器总是说“Employee::Employee”: 没有重载函数接受 2 个参数
展开
 我来答
terranlong
2014-06-11 · TA获得超过7294个赞
知道大有可为答主
回答量:2660
采纳率:0%
帮助的人:4002万
展开全部

Employee(string name,string id,string dept,float salary),原型有4个参数,但你只传了2个参数,应该改成

    Teacher(string title,string name,string id,string dept,float salary):Person(name,id),Employee(name,id,dept,salary),Title(title)
    {

    }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式