I am getting 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); //start of setters
void setEmployeeAddress(string add);
void setEmployeeTelephone(string tel);
void setEmployeeSalary(double sal);
string getEmployeeFirstName(); //start of getters
string getEmployeeLastName();
string getEmployeeAddress();
string getEmployeeTelephone();
double getEmployeeSalary();
int show();
};
#endif
Employee.cpp
#include"Employee.h"
#include<iostream>
#include<string>
using namespace std;
//start of constructors
Employee::Employee()
{
}
Employee::Employee(string fin, string lan, string add, string tel, double sal)
{
firstName = fin;
lastName = lan;
address = add;
telephone = tel;
salary = sal;
}
//end of constructors
//start of setters
void Employee::setEmployeeName(string fin, string lan)
{
cout<<"Please enter the Employee's first name: ";
cin>>fin;
cout<<"Please enter the Employee's last name: ";
cin>>lan;
firstName = fin;
lastName = lan;
}
void Employee::setEmployeeAddress(string add)
{
cout<<"Please enter the Employee's address: ";
cin>>add;
address = add;
}
void Employee::setEmployeeTelephone(string tel)
{
cout<<"Please enter the Employee's telephone number: ";
cin>>tel;
telephone = tel;
}
void Employee::setEmployeeSalary(double sal)
{
cout<<"Please enter the Employee's monthly salary: R";
cin>>sal;
salary = sal;
}
//end of setters
//start of getters
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;
}
//end of getters
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 spot what's wrong?
Thank you.
Ok I found the problem. There was some sort of file name Employee.h.gwh in the same directory that I have no idea where that came from, I delted it and works now. Thanks for the by the way.