Co-Authored By:
Asked by: Rajaa Bertomeu
family and relationships adoption and fosteringHow are protected members of a base class?
Furthermore, how do I access protected base class members?
A protected nonstatic base class member can be accessed by members and friends of any classes derived from that base class by using one of the following:
- A pointer to a directly or indirectly derived class.
- A reference to a directly or indirectly derived class.
- An object of a directly or indirectly derived class.
Similarly, you may ask, can objects of a class access protected members?
8 Answers. A class can only access protected members of instances of this class or a derived class. It cannot access protected members of instances of a parent class or cousin class. In your case, the Derived class can only access the b protected member of Derived instances, not that of Base instances.
Private members Public members public & protected members of base class B are now private Page 3 private members of the Base class are strictly non-inheritable under every derivation.