- Get objects to interact with each other: need conformance to a set of mutually agreed methods
- In other words, need an interface
- All classes derived from the interface implement the
interface methods as declared in the interface
- Can guarantee the formal behaviour of all derived objects
- In C++, an interface is known as a pure virtual class:
a class consisting only of method declarations and no data fields
- A pure virtual class has no constructor -- no object of
that class can ever be created (only objects of derived classes)
- A pure virtual class may have a virtual destructor to permit
correct destruction of derived objects
- All methods (except the destructor) are declared as follows:
returnType methodName(args) = 0;
- All derived classes must implement all methods
Leo Liberti
2008-01-12