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.
virtual void setName(string s)
class HumanPlayer : public Player
void setName(string s)
name = "h" + s;
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?
Any help is appreciated!
No. If you want the child to modify it, make it protected.