- We can replace class D with interface D where
the only difference is that value is only prototyped in the
interface whereas it is defined in class D (previous slide).
But the code for using objects as type D objects does not
change except that D objects cannot be created directly since
there is no D class - we can only create objects from classes
that implement the D interface and these also happen to be
type D objects.
- This means we do not have to extend classes to get a type
hierarchy - just make sure the classes that are developed implement
the appropriate interfaces. The services that would normally be
inherited from superclasses may now be obtained by creating an object
of a would-be superclass and using methods of that object. Normally,
in this case, the would-be superclass would require any class using
its methods to implement an appropriate interface - as though it had
been a superclass.