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 个参数 展开
#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 个参数 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询