A class may inherit data fields and method definitions from another class using the INHERITS keyword in its class definition:
define class class_name inherits parent_class ... enddefine
The newly defined class will contain all the data fields and methods belonging to the parent class, which in turn may inherit some of these definitions from still another class. The class being inherited from is called a base class for the new class.
For example, consider the following definition for a class called Shape:
define class Shape
ReadOnly
double CenterX
double CenterY
EndReadOnly
enddefine
define method SetCenter( X, Y ) on Shape
this.CenterX = x
this.CenterY = y
enddefine
Using Shape as a base class, the class Circle can be defined using inheritance as follows:
define class Circle inherits Shape
ReadOnly
double Radius
double Area
EndReadOnly
enddefine
define method SetRadius( radius ) on Circle
this.Radius = radius
this.Area = 3.1415927 * this.Radius * this.Radius
enddefine
Since this new definition of class Circle inherits from class Shape, the read-only data fields CenterX and CenterY of Shape automatically become part of Circle. Similarly, the method SetCenter defined on Shape also becomes a method of Class Circle. Hence this new definition of class Circle is equivalent to the earlier definition that did not use inheritance.
An advantage of using inheritance is that a base class can be used to derive other similar classes all sharing some common behavior, providing a convenient way to reuse definitions and code. For example, another class called Rectangle could also build upon shape as follows:
define class Rectangle inherits Shape
ReadOnly
double height
double width
double Area
EndReadOnly
enddefine
define method SetSize( height, width ) on Rectangle
this.Height = height
this.Width = width
this.Area = height*width
enddefine
A newly created subclass may not redefine any data fields that have already been defined by its parent class, nor can it change the access restrictions on data fields defined by the parent class. Methods may, however, be defined on the new class with the same name as methods defined on the parent class. In this case, the new class will no longer be able to access the method of the same name belonging to its parent class.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.