What is the main purpose of using protected access specifier in base class? 

  • To restrict all external access 
  • To allow all classes to access 
  • To enable inheritance only 
  • To share methods with friends
The protected access specifier in C++ is mainly used to ensure that members are inaccessible from outside the class (just like private members). However, the difference is that protected members can be accessed by derived classes. This allows for more secure inheritance, giving derived classes access without exposing to the external world.
Add your answer
Loading...

Leave a comment

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