Previous Topic Next topic Print topic


MF 

Class-body

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

  1. Class-name-3 must not be specified more than once in the Class-Control paragraph.
  2. Class-name-3 may be the same as the class-name specified in the Class-ID paragraph.
  3. The Data Division may not contain a Linkage Section.

Syntax Rules for Format 1

  1. The Data Division may not contain an Object-Storage Section.
  2. Data items declared in the Data Division may be referenced from instance methods and class methods.

Syntax Rules for Format 2

  1. 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.
  2. 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.
  3. Data items declared in the Object-Storage Section may be referenced from class methods.

General Rules for All Formats

  1. Class-name-3 is implicitly defined as USAGE IS OBJECT REFERENCE.
  2. Class-name-3 is the name of a class that may be used throughout the scope of the containing Environment Division.
  3. External-name-1 specifies the external name of the file containing the class.
  4. Method-1 is a class method.
  5. Only data items in the Object-Storage Section are inherited by subclasses.

General Rules for Format 1

  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

  1. 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.
  2. 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.
  3. 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.
  4. Data items declared in the Object-Storage Section remain in their last used state between invocations of class methods.
Previous Topic Next topic Print topic