Which access specifier allows a class member to be accessible only within its own class and friends?
- public
- protected
- private
- global
The private access specifier in C++ ensures that class members are accessible only within the class they are defined and by friend functions or classes. This helps in the principle of encapsulation, keeping data and methods secure from unintended access.
Loading...
Related Quiz
- What is the significance of the "default" case in a switch-case statement?
- An application performs arithmetic operations on various data types without modifying existing code. Which concept facilitates this?
- The _______ smart pointer in C++ does not allow the pointer to be shared among objects.
- The function _______ is used to close a file.
- In C++, if a class makes a non-member function its friend, that function gets the ability to access the _______ and _______ members of the class.