ValueType

値型には、クラスと同様にデータ メンバーおよび関数メンバーを含めることができます。違いは、値型はデータを値として保存し、ヒープ割り当てを必要としない点です。

コンテキスト:

プログラム構造 

valuetype-specification

valuetype-header constraints-paragraph static-or-instance-field static-or-instance-member

valuetype-header

access-modifier type-specifier attribute-clause

valuetype-id StudentRecord.
01 #name            string public.
01 averageMark      float-short public.

method-id new(studentName as string, averageMark as float-short).
    set self::name to studentName
    set self::averageMark to averageMark
end method.

end valuetype.

class-id RecordClient.

method-id main static.
    declare stu = new StudentRecord("Bob", 3.5).
    declare stu2 as type StudentRecord
    set stu2 to stu
    set stu2::name to "Sue"
    display stu::name   *> Prints Bob
    display stu2::name  *> Prints Sue
end method.

end class.

ValueType のサンプルも参照してください。このサンプルは、Start > All Programs > Micro Focus Enterprise Developer > Samples > Visual COBOL SamplesCOBOL for .NET の場合。 に用意されています。