Define a static constructor
- Last Updated: February 16, 2019
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
A static constructor is used to initialize the static data member for a class.
Here is the syntax for defining a static constructor:
constructor static <class-name> ():
<body of constructor>
end constructor.
Syntax Element | Description |
class-name | Must match the name of the class in the class definition. |
body of constructor | The ABL code necessary to implement the functionality of the constructor. |
Here is the code for the static constructor of the Corporation
class. Notice that it creates an instance of Enterprise.Corporation by
calling the default constructor for Enterprise.Corporation. In this static constructor,
you must fully specify the name of the class. The default constructor returns an
instance of Corporation. The static constructor then assigns this value
to the static data member named Instance. After this constructor runs,
there is a single instance of the Corporation class running in the AVM.
constructor static Corporation ( ):
Enterprise.Corporation:Instance = new Enterprise.Corporation().
end constructor.