The class body contains all the code that defines class data and class methods.
General Format for Format 1
Used when the Compiler directive OOCTRL(+N) is specified.
Note: This is the preferred syntax.
General Format for Format 2
Used when the Compiler directive OOCTRL(-N) is specified.
Syntax Rules for All Formats
- Class-name-3 must not be specified more than once in the Class-Control paragraph.
- Class-name-3 may be the same as the class-name specified in the Class-ID paragraph.
- The Data Division may not contain a Linkage Section.
Syntax Rules for Format 1
- The Data Division may not contain an Object-Storage Section.
- Data items declared in the Data Division may be referenced from instance methods and class methods.
Syntax Rules for Format 2
- Data items declared in the Local-Storage Section, Report Section, and Screen Section may be referenced only from the statements in the Procedure Division of this class, not from any methods.
- Data items declared in the File Section or Working-Storage Section can be referenced from instance methods and class methods and from the Procedure Division of this class.
- Data items declared in the Object-Storage Section may be referenced from class methods.
General Rules for All Formats
- Class-name-3 is implicitly defined as USAGE IS OBJECT REFERENCE.
- Class-name-3 is the name of a class that may be used throughout the scope of the containing Environment Division.
- External-name-1 specifies the external name of the file containing the class.
- Method-1 is a class method.
- Only data items in the Object-Storage Section are inherited by subclasses.
General Rules for Format 1
- Data items are in their initial state at the start of the run unit and remain in their last used state between method invocations.
General Rules for Format 2
- The statements in the class Procedure Division are executed before the first time any class method or instance method of this class is executed in the run unit.
- When execution of the class Procedure Division begins, the contents of the data items in the Local-Storage Section are undefined. This storage is deallocated immediately after execution of the class Procedure Division.
- Data items declared in the File Section and Working-Storage Section remain in their last used state between invocations of class and instance methods.
Note: Working storage data is useful for class or instance initialization data.
- Data items declared in the Object-Storage Section remain in their last used state between invocations of class methods.