Object::Interface - allows specification of an abstract base class
package abstract; use strict; use Object::Interface qw( func1 func2 func3 ); 1; # Any classes derived from abstract must now contain the functions # specified in the 'use' statement, e.g. func1, func2, and func3.
Object::Interface allows class modules to be declared as abstract base classes, or in C++ parlance, pure virtual classes. That is to say, any class derived from a module using Object::Interface must implement the specified routines from that module. Object::Interface differs from C++'s pure virtual functions in that functions may be defined and coded in the abstract base for the derived class to call (via SUPER). This allows common code to be written in the base class. For example:
Object::Interface
SUPER
package IO::Base; use strict; use Object::Interface qw( open close read print eof ); # etc. sub open { return open @_; } # etc.
Object::Interface simply specifies a signature of functions that any derived class must implement, not what the derived class can or cannot do with the methods.
To install Object::Interface, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Interface
CPAN shell
perl -MCPAN -e shell install Object::Interface
For more information on module installation, please visit the detailed CPAN module installation guide.