Creating interfaces
An interface class is an OO concept of a class that is a further refinement of an abstract class. Whereas an abstract class can contain generalized attributes and default behaviors (by including data members and default definitions for pure virtual functions or by providing non-virtual member functions), an interface class will only contain abstract methods. An abstract class in C++ containing only abstract methods (that is, pure virtual functions with no optional definitions) can be thought of as an interface class.
When considering interface classes as implemented in C++, it is useful to remember the following:
- Abstract classes are not instantiable; they provide (via inheritance) the interfaces (that is, operations) that a derived class must offer.
- Although a pure virtual function may contain an optional implementation (that is, method body) in the abstract class, this implementation should not be provided if the class wishes to be considered...