Interfaces

An interface is a list of instance methods specifying names and signatures but without implementation.

interface-specification

Syntax for interface-specification 
 interface-header constraints-paragraph interface-member

interface-header

Syntax for interface-header 
 access-modifier type-specifier attribute-clause generic-using-phrase

interface-member

Syntax for interface-member
 method-specification property-specification indexer-specification

Example

*> Interface definition
interface-id IClock
01 Hour      binary-long property with no set.
01 Minute    binary-long property with no set.

method-id Reset.
end method.

end interface.

*> Extending an interface
interface-id IAlarmClock implements type IClock.
01 AlarmHour   binary-long property.
01 AlarmMinute binary-long property.

method-id Snooze (#time as binary-long).
end method.

end interface.

*> Interface implementation
class-id WristWatch implements type IAlarmClock,
                               type System.IDisposable.

working-storage section.
01 Hour        binary-long property with no set.
01 Minute      binary-long property with no set.
01 AlarmHour   binary-long property.
01 AlarmMinute binary-long property.
method-id Dispose.
    invoke self::Reset()
end method.

method-id Reset.
    set Hour to 0
    set Minute to 0
    set AlarmHour to 0
    set AlarmMinute to 0
end method.

method-id Snooze (#time as binary-long).
    add #time to AlarmMinute
end method.

end class.

See also the Interfaces sample, which is available from Start > All Programs > Micro Focus Enterprise Developer > Samples > Visual COBOL Samples, under COBOL for .NET.

About Interfaces

An interface is a list of instance methods specifying names and signatures but without implementation.

When a program declares that it implements a particular interface this means that the program is required to have implementations for all the methods defined in the interface. To implement an interface you use the IMPLEMENTS phrase of the OBJECT clause in a class definition to declare that a program provides an implementation for the specified interface. You can also declare an object reference to this interface type.