Think like an onion. Each level of the hierarchy is a layer inside the bow. For example, if class C extends class B, which extends class A, then an object of class C will look like this:
Class C Object
------------------------------------------------------------- | | | C and it members | | | | ------------------------------------------------ | | | | | | | B and it members | | | | ------------------------------------ | | | | | A and it members | | | | | | | | | | | ------------------------------------ | | | ------------------------------------------------ | | | -------------------------------------------------------------
So, an object of class C has members B and A. But it cannot access private members B and A.
However, he may contact the public and protected members B and A.
Thus, the public access function for B will either allow this class C object to access the private instance variable of class B or class A part of the "object."
source share