+ 2

What is protected access specifier in cpp?

10th Apr 2018, 3:32 PM
Frankestine Stine
Frankestine Stine - avatar
4 Antworten
+ 5
Protected members are accessible within the same class and classes derived from it but not other classes.
11th Apr 2018, 2:33 AM
Rusty.Metal
+ 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
10th Apr 2018, 3:46 PM
Jeya Prakash J
Jeya Prakash J - avatar
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.
10th Apr 2018, 3:44 PM
TurtleShell
TurtleShell - avatar
0
Hello
3rd May 2019, 6:22 AM
narjes
narjes - avatar