I've got one base class/parent class: Person
And two subclasses/child classes: Player, Coach
This is what the header for the base class Person looks like:
class Person
{
public:
Person(string name);
Person();
virtual ~Person();
string getName();
void setName(string name);
virtual void printSpec() const = 0;
private:
string name;
};
I tried to compile and run, it started complaining about this:
include\Person.h||In constructor 'Coach::Coach(std::string, std::string)':|
include\Person.h|19|error: 'std::string Person::name' is private|
\src\Coach.cpp|5|error: within this context|
||=== Build finished: 2 errors, 0 warnings ===|
And pointed to this:
private:
string name;
In the context of one out of two constructors for the child class "Coach":
Coach::Coach(string name, string responsibility): Person(name){
this->name = name;
this->responsibility = responsibility;
}
However, it doesn't make the same complaint about that very same line in the constructor of the "Player"-class, only complains about "string name being a private member" in the constructor of the "Coach"-class.
I looked up some solutions for other people, tried protected instead of private, tried changing the names of the variables, but to no use.
What gives?