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

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What can access a protected member of a class?

  1. Only the same class members

  2. Only friend functions

  3. Derived classes, but not unrelated functions

  4. Anyone

The correct answer is: 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.