Which access specifier allows members of a class to be accessed only by member functions of the same class and its derived classes in C++?
A. protected
B. public
C. private
D. friend
Answer: Option A
Solution (By Examveda Team)
Access specifiers in C++ determine the visibility and accessibility of class members.The protected access specifier allows members of a class to be accessed by:
1. Member functions of the same class
2. Member functions of its derived (child) classes
This makes protected different from private, which restricts access only to the class itself, and from public, which allows access from anywhere.
Now let’s see why the other options are incorrect:
Option B: public — Members are accessible from anywhere in the program, which is more permissive than required by the question.
Option C: private — Members are accessible only within the same class, not by derived classes, so this is too restrictive.
Option D: friend — friend is not an access specifier; it is a keyword used to allow a specific external function or class to access private or protected members of another class. It doesn’t define a general access level.
Conclusion: The protected access specifier is the one that allows class members to be accessed within the same class and its derived classes.
Hence, the correct answer is Option A: protected.
Join The Discussion
Comments (1)
Related Questions on Classes and Objects in C plus plus
A. A collection of functions
B. A reserved keyword in C++
C. A blueprint for creating objects
D. A way to declare arrays of data
Which keyword is used to create an object of a class in C++?
A. new
B. create
C. object
D. None of the above
A. A reserved keyword in C++
B. An instance of a class
C. A way to declare arrays of data
D. None of the above
What is the purpose of a constructor in C++?
A. To hide the implementation details of a class
B. To create multiple instances of a class
C. To initialize the object's data members
D. To destroy the object

the correct answer of this question will be protected.
protected means same class and its derived class.