Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++

Question: 1 / 565

What can access a protected member of a class?

Only the same class members

Only friend functions

Derived classes, but not unrelated functions

Protected members of a class can only be accessed by the same class members, such as constructors, member functions, and friend classes, as well as derived classes. This means that options A and B are partially incorrect since they do not include derived classes as an option. Option D is completely incorrect since anyone outside of the class or its derived classes cannot access protected members. Option C is the correct choice as it provides the most accurate and complete explanation of the access restrictions for protected members.

Get further explanation with Examzify DeepDiveBeta

Anyone

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy