I am having trouble modifying a private member of a base class when using inheritance. Can please shed light on why this doesn't work and explain a workaround if one is needed.
class Player
{
public:
virtual void setName(string s)
{}
private:
string name;
};
class HumanPlayer : public Player
{
public:
void setName(string s)
{
name = "h" + s;
}
private:
};
This gives me an error on compilation saying name is private and thus can't be modified. Shouldn't inheritance allow me to modify it?