14.5. 14.5 Inheritance

Inheritance is one of the most fundamental ideas behind object-oriented programming. The basic idea is that a class inherits, or copies, all the fields from some class and then possibly expands the number of fields in the new data type. For example, suppose you created a data type point that describes a point in the planar (two dimensional) space. The class for this point might look like the following:

type
     point: class

          var
               x:int32;
               y:int32;

          method distance;

     endclass;

Suppose you want to create a point in 3D space rather than 2D space. You can easily build such a data type as follows:

type
     point3D: class inherits( point )

          var
               z:int32;

     endclass;

The inherits option on the class declaration tells HLA to insert the fields of ...

Get Art of Assembly Language, 1st Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.