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

Question: 1 / 565

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

Public

Private

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.

Get further explanation with Examzify DeepDiveBeta

Friend

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy