The assignment Im working on involves creating a database of employees and outputing some basic information about them. Im having trouble in my header class files. the error i get is "error: passing 'const Owner' as 'this' argument of 'double Employee::getSalary()' discards qualifiers"
I think its the way im passing the mySalary into the display but im a bit stumped on how to get around this without having to create a calculate_salary() function and calculate the salary in the driver program.
#include <iostream>
#ifndef EMPLOYEE
#define EMPLOYEE
class Employee
{
public:
Employee(long id = 0, string last = "", string first = "",char EmpClass = ' ', double salary = 0);
virtual void display(ostream & out)const;
double getSalary();
private:
long myId;
string myLastName,myFirstName;
char myEmpClass;
double mySalary;
};
inline Employee::Employee(long id, string last, string first, char EmpClass, double salary)
: myId(id), myLastName(last), myFirstName(first),myEmpClass(EmpClass), mySalary(salary)
{ }
inline void Employee::display(ostream & out)const
{
out << myId << endl << myLastName << ", "
<< myFirstName << endl << myEmpClass << endl
<< "$" << mySalary << endl;
}
inline ostream & operator<<(ostream & out, const Employee & emp)
{
emp.display(out);
return out;
}
double Employee::getSalary()
{
return this->mySalary;
}
#endif
#include "Employee.h"
#ifndef OWNER
#define OWNER
class Owner : public Employee
{
public:
Owner (long id = 0, string last = "",string first = "", char EmpClass = ' ', double salary = 0, double profit = 0);
virtual void display(ostream & out)const;
private:
double myProfit;
};
inline Owner::Owner(long id, string last, string first, char EmpClass, double salary, double profit)
: Employee(id, last, first, EmpClass, salary), myProfit(profit)
{ }
inline void Owner::display(ostream & out)const
{
Employee::display(out);
out << "This month's pay: $" << getSalary() + myProfit*.6 << endl;
}
#endif
these are just the 2 header files(employee is the base class). Im pretty sure that my driver file is fine as it just creates and cout the objects, but if you need to see it then ill throw it up there.
Thanks again in advance