I'm new to C++. I have searched my question here, but did not find an answer.. So, I have parent and child classes:
class Animal {
protected:
Animal *_father;
Animal *_mother;
string _name;
public:
...
};
class Lion: protected Animal {
private:
...
public:
...
};
I have a method in Lion class that has to print the animal itself and its parents names.
So I want to get the _name
field of a parent.
I have tried to do : _mother->_name
And the error is: 'name' is a protected member of 'Animal'
I'm pretty sure that inheritance should solve this...
I'll be glad for any help!Thanks you all