Question 14
Back to Exercise
Why do many guidelines prefer private data with protected member functions over protected data members?
- A Protected data is slower
- B Every derived class – including ones written later – can modify protected data, so the base class cannot guarantee its invariants Correct
- C Protected data cannot be initialized
- D Protected data is not inherited
Correct Answer: Option B
Protected functions let derived classes change state only through checked operations.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!