コンストラクタ

コンストラクタは、クラスの作成時に実行されるクラス・メソッドです。

constructor-specification

constructor-header procedure-division

constructor-header

attribute-clause

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.

その他の情報

コンストラクタは、クラスの作成時に実行されるクラス・メソッドです。コンストラクタの名前は「new」になり、RETURNING 項目はありません。

クラスは、異なる引数で複数のコンストラクタを定義できます。

コンストラクタを定義しない場合、コンパイラはデフォルトのコンストラクタを生成します。