Hi guys.
I am current facing an annoying problem. I have written the following classes:
Code:
#ifndef _EMPLOYEE_H
#define _EMPLOYEE_H
#include <string>
using namespace std;
class Employee {
public:
Employee(string theName, float thePayRate);
string getName() const;
float getPayRate() const;
float pay(float hoursWorked) const;
protected:
string name;
float payRate;
};
#endif /* not defined _EMPLOYEE_H */
Code:
#include "employee.h"
using namespace std;
int main(){}
Employee::Employee(string theName, float thePayRate)
{
name = theName;
payRate = thePayRate;
}
string Employee::getName() const
{
return name;
}
float Employee::getPayRate() const
{
return payRate;
}
float Employee::pay(float hoursWorked) const
{
return hoursWorked * payRate;
}
Code:
#ifndef _MANAGER_H
#define _MANAGER_H
#include <string>
#include "employee.h"
using namespace std;
class Manager : public Employee {
public:
Manager(string theName,float thePayRate,bool isSalaried);
bool getSalaried() const;
float pay(float hoursWorked) const;
protected:
bool salaried;
};
#endif /* not defined _MANAGER_H */
Code:
#include "manager.h"
using namespace std;
int main(){}
Manager::Manager(string theName,float thePayRate,bool isSalaried): Employee(theName, thePayRate)
{
salaried = isSalaried;
}
bool Manager::getSalaried() const
{
return salaried;
}
float Manager::pay(float hoursWorked)
{
if (salaried)
return payRate;
/* else */
return Employee::pay(hoursWorked);
}
I have tried to compile manager.cpp many times in Dev C++ 4.9.9.2 but the message are always:
Code:
[Linker error] undefined reference to `Employee::Employee(std::string, float)'
[Linker error] undefined reference to `Employee::Employee(std::string, float)'
[Linker error] undefined reference to `Employee::pay(float) const'
ld returned 1 exit status
Can anyone help me?Thank you in advance =)