Inheritance and Class Structure
OOP allows subclasses to extend a class, both in terms of instance
variables and methods.
A common practice it to let subclasses add instance variables;
the subclass inherits all instance variables of its parent.
- Subclasses simply add variables to the end of the record.
- Methods inherited from a superclass are guaranteed to work, since
all needed instance variables will be available at the same constant offsets
from the beginning of the record.
- It is not possible to change an object from a superclass to one of
its subclasses, since that would increase its size after it is allocated.
Multiple inheritance could cause problems of inconsistent offsets
or name conflicts.