Which statement about protected members in C++ inheritance is correct?

Options

  • A. Protected members are accessible from unrelated classes
  • B. Protected members can be accessed directly by any object from outside the class
  • C. Protected members can be accessed within derived-class member functions, subject to C++ access rules
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Protected members can be accessed within derived-class member functions, subject to C++ access rules

Detailed Explanation

Correct Answer: Option C

Explanation:
A protected member is accessible within its class and appropriate derived-class member functions. It is not generally accessible directly through an object from unrelated outside code. Exact access also depends on the inheritance mode and the object through which the member is accessed.