Hi Precila. Your question makes absolutely no sense at all.:) When you say protected and private, what do you mean by that?
AndreRet
Senior Poster
3,918 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
>Private data members cannot be accessed outside the class.
Yes.
>When a class inherits a base class, all the data members except the private get inherited into it.
Private members are inherited, but not accessible from the child class.
>So if we want data members to be accessible to only derived classes
>and not privately or publicly accessible, then we can use protected.
While not incorrect, this answer is the kind of cookie cutter thing you'd get right out of a textbook. It shows knowledge, but not necessarily understanding.
A better answer would give a practical example for using protected, explain why it's preferred, then derive a more general guideline from the explanation. This covers all bases in that it shows you can think of a good situation where protected makes sense (understanding of the concept), defend the decision (understanding the pros and cons versus alternatives), and draw a logical conclusion (show creativity and independent thought).
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
AndreRet
Senior Poster
3,918 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350