+ 1
Where and how to access protected members?
I want to know when is protected specifier used and how to access it?
1 Respuesta
+ 5
Do you mean C++?
It is usually used when you want to access "private" members of a base class from an inherited class. To do this, the members need to be protected instead of private, otherwise the derived/inherited class cannot see them.
You access the members just as usual, like you would do for public members.
Access from outside of the class only through getters and setters like in case of private members.