Previous Topic Next topic Print topic


Interfaces

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

interface-specification

interface-header constraints-paragraph interface-member

interface-header

access-modifier type-specifier attribute-clause generic-using-phrase

interface-member

method-specification property-specification indexer-specification

Example

*> Accessibility keywords
*>public
*>private
*>internal
*>protected
*>protected internal
*>static

class-id Competition.

end class.

*> Inheritance
class-id FootballGame inherits type Competition.

end class.


*> Interface definition
interface-id IClock.

end interface.

interface-id ITimer.

end interface.

*> Extending an interface 
interface-id IAlarmClock inherits type IClock.

end interface.


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

end class.

See also the Interfaces sample, which is available from Start > All Programs > Micro Focus 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.

Previous Topic Next topic Print topic