I get a very annoying error with my g ++ compiler in Ubuntu.
This is my code.
Employee.h
#ifndef Employee_h
#define Employee_h
#include<string>
using namespace std;
class Employee
{
protected:
int employeeNumber;
string firstName;
string lastName;
string address;
string telephone;
double salary;
int generateEmployeeNumber();
public:
Employee();
Employee(string fin, string lan, string add, string tel, double sal);
void setEmployeeName(string fin, string lan);
void setEmployeeAddress(string add);
void setEmployeeTelephone(string tel);
void setEmployeeSalary(double sal);
string getEmployeeFirstName();
string getEmployeeLastName();
string getEmployeeAddress();
string getEmployeeTelephone();
double getEmployeeSalary();
int show();
};
#endif
Employee.cpp
#include"Employee.h"
#include<iostream>
#include<string>
using namespace std;
Employee::Employee()
{
}
Employee::Employee(string fin, string lan, string add, string tel, double sal)
{
firstName = fin;
lastName = lan;
address = add;
telephone = tel;
salary = sal;
}
void Employee::setEmployeeName(string fin, string lan)
{
cout<<"Please enter the Employee first name: ";
cin>>fin;
cout<<"Please enter the Employee last name: ";
cin>>lan;
firstName = fin;
lastName = lan;
}
void Employee::setEmployeeAddress(string add)
{
cout<<"Please enter the Employee address: ";
cin>>add;
address = add;
}
void Employee::setEmployeeTelephone(string tel)
{
cout<<"Please enter the Employee telephone number: ";
cin>>tel;
telephone = tel;
}
void Employee::setEmployeeSalary(double sal)
{
cout<<"Please enter the Employee monthly salary: R";
cin>>sal;
salary = sal;
}
string Employee::getEmployeeFirstName()
{
return firstName;
}
string Employee::getEmployeeLastName()
{
return lastName;
}
string Employee::getEmployeeAddress()
{
return address;
}
string Employee::getEmployeeTelephone()
{
return telephone;
}
double Employee::getEmployeeSalary()
{
return salary;
}
And this is my ERROR:
Employee.cpp:31:6: error: prototype for โvoid Employee::setEmployeeName(std::string, std::string) does not match any in class โEmployee
Employee.h:22:16: error: candidate is: void Employee::setEmployeeName()
Employee.cpp:42:6: error: prototype for โvoid Employee::setEmployeeAddress(std::string) does not match any in class โEmployee
Employee.h:23:7: error: candidate is: int Employee::setEmployeeAddress(std::string)
Employee.cpp:49:6: error: prototype for โvoid Employee::setEmployeeTelephone(std::string) does not match any in class โEmployee
Employee.h:24:7: error: candidate is: int Employee::setEmployeeTelephone(std::string)
Employee.cpp:56:6: error: prototype for โvoid Employee::setEmployeeSalary(double) does not match any in class โEmployee
Employee.h:25:10: error: candidate is: double Employee::setEmployeeSalary(std::string)
Can anyone determine what is wrong?
Thank.
Ok, I found a problem. In the same directory there was some name of the file Employee.h.gwh, I have no idea where it came from, I deleted it and now I'm working. Thanks for the way.
source
share