Asked by: Rajaa Bertomeufamily and relationships adoption and fostering
How are protected members of a base class?
Last Updated: 2nd May, 2020
Click to see full answer.
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.
Also Know, what is a protected class member? Protected members are accessible in the class that defines them and in classes that inherit from that class. Edit: Both are also accessible by friends of their class, and in the case of protected members, by friends of their derived classes.
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.
Can private members of a base class are inheritable?
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.