#ifndef EMPLOYEE_H
#define EMPLOYEE_H
// DO NOT MODIFY THIS FILE IN ANY WAY
#include <string>
#include "person.h"
class Employee
{
public:
Employee();
Employee(const std::string& employeeName, double initialSalary);
void setSalary(double newSalary);
double getSalary() const;
std::string getName() const;
private:
Person personData;
double salary;
};
#endif
The code here does not recognize the name previously declared in the person class. I am having trouble getting this class to recognize the "string name" previously declared in the person.
I'm assuming your talking about the second constructor in the employee class. In order to be able to use the name instance variable of the person class you need to create a person object. If you intend for the employee class to have the instance variables of the person class you must use inheritance or pass the variable to one of the methods in the employee class.
Employee::Employee() : personData(), salary(0.0) // I don't know what to put inside personData. I keep getting errors if I put in "".
{ }
Employee::Employee(const string& employeeName, double initialSalary)
: personData(employeeName), salary(initialSalary) // personData has error here too.
{ }