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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *