A class can define a special method called a constructor, which allows you to execute behavior and initialize data members and properties during the instantiation of a class. ABL allows you to define a constructor as a named block that always begins with the CONSTRUCTOR statement and always ends with the END CONSTRUCTOR statement. A constructor must have the same name as the name of the class in which it is defined and it can only execute when the class is instantiated. A constructor can be defined with an access mode of PRIVATE, PROTECTED, or PUBLIC, where PUBLIC is the default.
PROTECTED — A protected constructor can be invoked by another constructor of the class or from a constructor of a subclass. An instance can invoke a protected constructor as long as the constructor is defined in the same class as the instance or a super class of the instance. If all constructors of the class are defined as
PROTECTED, this class can only be instantiated indirectly when you directly instantiate a subclass of this class.
A constructor can also have parameters, but no defined return type. You can define more than one constructor (overload constructors) in a class as long as the calling signature of each constructor is unique.
ABL also supports a static constructor that initializes static data for a class type instead of instance data (for a class instance) as with instance constructors. Unless otherwise specified, any reference to a constructor in this manual refers to an instance constructor. For more information on static constructors, see
Usingstatic members of a class.
For information on the ABL to instantiate a class, see
Creating and destroying a class instance. For more information on defining constructors, see
Definingclass constructors.