+ 1

Where and how to access protected members?

I want to know when is protected specifier used and how to access it?

7th Nov 2018, 5:20 PM
Shivam Gavandi
Shivam Gavandi - avatar
1 Answer
+ 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.
7th Nov 2018, 5:25 PM
Matthias
Matthias - avatar