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.


Which access specifier would you use to hide data members from the user of the class while allowing derived classes to access them?

  1. Public

  2. Private

  3. Protected

  4. Friend

The correct answer is: Protected

Protected access specifier is used to hide data members from the users of the class, while allowing derived classes to access them. Public access would allow anyone to access the data members, private access would only allow the class itself to access the data members, and friend access would only allow designated friend classes to access the data members. Therefore, protected is the most appropriate access specifier for this scenario.