Previous Topic Next topic Print topic


Constructors

A constructor is a class method that is executed when the class is created.

constructor-specification

constructor-header procedure-division

constructor-header

attribute-clause

Example

method-id new.
procedure division.
    set powerLevel to 0
end method.
 
method-id new.
procedure division using by value powerLevel as binary-long.
    set powerLevel to powerLevel
end method.

Further Information

A constructor is a class method that is executed when the class is created. Constructors are named "new", and do not have a returning item.

A class can define multiple constructors with different arguments.

If no constructor is defined, the Compiler generates a default one.

Previous Topic Next topic Print topic