Which access specifier in C++ allows a class member to be accessible only within the class and friends of the class?
- public
- private
- protected
- external
The private access specifier in C++ ensures that class members are only accessible within the class and not outside. Additionally, friend functions or classes can access these private members, but they remain hidden from other parts of the program.
Loading...
Related Quiz
- What is the primary purpose of a constructor in a class?
- The concept of Streams in C++ was introduced in the standard with _______.
- The concept of encapsulation involves bundling the data () and the methods () that operate on the data into a single unit.
- You are designing a complex numerical algorithm with multiple cooperating classes that need to share internal data for efficiency. How might the friend keyword be used effectively in this context?
- 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.