-1
看着类似的线程,这并没有显示出来。基本上我想要厨师继承雇员(基类)的功能和数据,但我与派生类的构造函数有问题。我得到的错误:没有匹配的函数调用'Employee :: Employee()'有人可以告诉我如何声明我的构造函数为这个派生类和我未来的派生类为这个程序。试了一堆东西,似乎无法让它工作。错误:没有匹配函数调用'Employee :: Employee()'
class Employee
{
public:
Employee(int theempID, string thefirstName, string thelastName, char theempClass, int thesalary)
{
this->empID = theempID;
this->firstName = thefirstName;
this->lastName = thelastName;
this->empClass = theempClass;
this->salary = thesalary;
};
protected:
int empID;
string firstName;
string lastName;
char empClass;
int salary;
};
class Chef : public Employee
{
public:
Chef(int theempID, string thefirstName, string thelastName, char theempClass, int thesalary, string theempCuisine) : Employee() {}
{
this->empID = theempID;
this->firstName = thefirstName;
this->lastName = thelastName;
this->empClass = theempClass;
this->salary = thesalary;
this->empCuisine = theempCuisine;
};
string getCuisine()
{
return empCuisine;
}
protected:
string empCuisine;
};
#endif // EMPLOYEE
很好的解释,如果可以的话,我会投票。感谢您的指导。 –
如果答案是好的,请接受它。希望你能做到这一点。 :) –