+ 2
What is protected access specifier in cpp?
4 Respostas
+ 5
Protected members are accessible within the same class and classes derived from it but not other classes.
+ 2
There are 3 access specifiers for a class/struct/Union in C++. These access specifiers define how the members of the class can be accessed. Of course, any member of a class is accessible within that class(Inside any member function of that same class). Moving ahead to type of access specifiers, they are:
Public - The members declared as Public are accessible from outside the Class through an object of the class.
Protected - The members declared as Protected are accessible from outside the class BUT only in a class derived from it.
Private - These members are only accessible from within the class. No outside Access is allowed. ok
0
Protected is similar to private as anything outside the class cannot access it, but private variables & methods cannot be inherited but protected can be inherited by the subclass.
0
Hello