Protected members in base Class best approach
i want to is what is the best approach with making the base class member variable protected that are common to all the sub classes.
I want to know that is there some design issues if me make the member variables in the b开发者_StackOverflow中文版ase class protected instead of making there getter and setters protected.
Setters and getters are there to control outside access to the members (and add the opportunity to include some logic while doing so).
If you're inheriting from a class, the member is yours, so if you want to access the member internally you can just make it protected for all the base classes and use it directly.
That's why they invented "protected".
精彩评论