Protected Access Specifier:
The public members of a class are accessible by all functions in the program and the private members of a class are accessible only by member functions and friend functions of that class. Similarly, the protected members of a class are accessible by the member functions and friend functions of that class.
The protected members of a base class are, however, accessible by members of its derived classes hut the private members of the base class are not accessible directly by members of its derived classes. This is the main difference between the protected and the private access specifiers.
The protected members of a base class fall between private and public member. These members are public for the derived class but for the rest of the program, these are treated as private.
comment closed