+ 1

Are protected members accesible from the base class and the derived class or only from the derived class?

10th Jan 2017, 2:53 PM
Enrique de la Cal
Enrique de la Cal - avatar
3 Answers
+ 1
protected => same class and derived private => only class
10th Jan 2017, 3:03 PM
nextco - avatar
protected members of the base class are accessible from the derived class only, but not the other way round. In other words, members of the derived class ( either protected or not) can not be accessed from the base class.
23rd Jan 2017, 11:49 AM
Raheem Kareem
Raheem Kareem - avatar
Members declared within the base class would always be accessible by the base class, whether protected or not (as it's within the same class). The protected members differ only when a derived class is trying to access them. Members in the derived class would not be accessible to the base class as the derived class essentially wouldn't exist before the base class is compiled.
13th Mar 2017, 9:25 AM
John Foster