Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


17.1.3 Inheritance

The remaining OOP concept of interest is inheritance. This is a grand name for a way of building on classes that enables the derived (i.e., bigger) class to be used as if its objects were really members of the inherited, or base, class. For example, suppose class D were derived from class B, so D is the derived class and B is the base class. In this case, class D inherits the data structure of class B, and may add extra data to it. It also inherits all the methods of class B, and objects of class D may be treated as if they were really objects of class B.

Of course, an inherited method cannot affect the extra data in class D, only the inherited data. To affect the extra data, class D can have extra methods defined, or it can make new definitions for the inherited methods. The latter approach is only really useful if the new definition of an inherited method is pretty similar to the inherited method, differing only in how it affects the extra data in class D. This overriding of methods does not affect the methods in class B (nor those of other classes derived from B), but only those in class D and the classes derived from D.


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.