错误:没有匹配的函数可用于调用“Faculty::Faculty()”在 c++
我在运行以下代码时收到此[ERROR
][1]。我是 C++ 世界的新手,我遇到了这个错误,如果有人能帮助我解决这种错误,那就太好了。提前致谢 :)。
- 这是错误->
!
#include <iostream>
#include <string>
using namespace std;
class Employee{
public:
string name;
string organisation;
string qualification;
int salary;
Employee(){
cout<<"Enter Employee name: ";
cin>>name;
cout<<"Enter organisation: ";
cin>>organisation;
cout<<"Enter qualification: ";
cin>>qualification;
}
void disp(){
cout<<"The Name of the employee is: "<<name<<endl;
cout<<"The Employee's organisation: "<<organisation<<endl;
cout<<"The Qualification of the employee is: "<<qualification<<endl;
}
virtual void print(){
cout<<"Inside Emplyee!";
}
};
class Faculty:public Employee{
public:
string course;
int workload;
Faculty(string course, int workload){
cout<<"Enter course: ";
cin>>course;
cout<<"Enter Workload: ";
cin>> workload;
}
void print(){
cout<<"Course: "<<course<<endl;
cout<<"Workload: "<<workload<<endl;
}
};
class Staff: public Employee{
public:
string designation;
string job_description;
Staff(string designation, string job_description){
cout<<"Enter designation: ";
cin>>designation;
cout<<"Enter job_description: ";
cin>>job_description;
}
void print(){
cout<<"Designation: "<<designation<<endl;
cout<<"Job Description: "<<job_description<<endl;
}
};
int main(){
//This program is written by kajal
Employee e;
e.disp();
Faculty f;
f.print();
return 0;
}
这是实际的问题, 定义一个带有数据成员的 Employee 类——姓名、组织、资格和薪水。在此类中定义成员函数,如下所示:
用于初始化数据成员的无参数构造函数 - 名称, 组织机构、资质及薪资。
用于显示姓名、组织、资格和薪水的函数 disp()。 • 纯净的 虚函数 void print()。
使用公共继承从 Employee 类派生类Faculty。在Faculty类中声明数据成员:Course和Workload(教员的工作时间) 一周)适当的数据类型,并定义一个参数构造函数来初始化这些数据成员。重写Faculty类中的print()函数来显示课程和 工作量。
使用公共继承从 Employee 类派生类 Staff。该派生类声明适当数据类型的数据成员 -Designation 和 Job_Description。
定义此类的参数构造函数来初始化 Designation 和 Job_Description 的值。重写此类中的打印函数以显示 Designation 和 Job_Description 。
定义main()函数并为Faculty类和Staff类各声明一个对象。 使用运行时多态性并显示Faculty和Staff类对象的详细信息。
I am getting this [ERROR
][1] on running the below code. I am a new bee in c++ world who got this error if someone could just help me to solve this kind of error that will be great. Thanks in Advance :).
- Here's the error->
!
#include <iostream>
#include <string>
using namespace std;
class Employee{
public:
string name;
string organisation;
string qualification;
int salary;
Employee(){
cout<<"Enter Employee name: ";
cin>>name;
cout<<"Enter organisation: ";
cin>>organisation;
cout<<"Enter qualification: ";
cin>>qualification;
}
void disp(){
cout<<"The Name of the employee is: "<<name<<endl;
cout<<"The Employee's organisation: "<<organisation<<endl;
cout<<"The Qualification of the employee is: "<<qualification<<endl;
}
virtual void print(){
cout<<"Inside Emplyee!";
}
};
class Faculty:public Employee{
public:
string course;
int workload;
Faculty(string course, int workload){
cout<<"Enter course: ";
cin>>course;
cout<<"Enter Workload: ";
cin>> workload;
}
void print(){
cout<<"Course: "<<course<<endl;
cout<<"Workload: "<<workload<<endl;
}
};
class Staff: public Employee{
public:
string designation;
string job_description;
Staff(string designation, string job_description){
cout<<"Enter designation: ";
cin>>designation;
cout<<"Enter job_description: ";
cin>>job_description;
}
void print(){
cout<<"Designation: "<<designation<<endl;
cout<<"Job Description: "<<job_description<<endl;
}
};
int main(){
//This program is written by kajal
Employee e;
e.disp();
Faculty f;
f.print();
return 0;
}
Here's it's actual Question,
Define a class Employee with data members – Name, Organization, Qualification and Salary. In this class define member functions as given below:
parameterless constructor to initialize the data members - Name,
Organization, Qualification and Salary.A function disp() for displaying the Name, Organization, Qualification and Salary. • A pure
virtual function void print().Derive the class Faculty from the Employee class using public inheritance. In the Faculty class declare data members: Course and Workload(number of working hours of a faculty in
a week) of the appropriate data type and define a parametric constructor for initializing these data members. Override the print() function in Faculty class to display the Course and
Workload .Derive a class Staff from the Employee class using public inheritance. This derived class declares data members -Designation and Job_Description of the appropriate data type.
Define the parametric constructor of this class to initialize the values of Designation and Job_Description. Override the print function in this class to display Designation and Job_Description .
Define the main() function and declare one object each of Faculty class and Staff class.
Use run time polymorphism and display the details of Faculty and Staff class objects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论