You can view a derived class object as having a complete base class object inside it. Let's assume that the
Entity class defines the fields
position, and methods
Playable class adds a field
playerID, and the
Wizard class adds a
spells field (an array of spells
they can cast) and a
Wizard object contains all the elements inside its box, include those of the base classes. So, for example, the complete set of properties in a
Wizard object is:
Wizard reference to a
Wizard object has access to any public elements from
any class in the inheritance chain from
Wizard. Code inside the
Wizard class has access to all elements of the base classes (except those
private in the base class - those are present, but not directly accessible).
A more complete description of access levels is coming up.
Note: although it appears that a base class object is physically located inside the derived class instance, it is not actually implemented that way.