Implementing abstract classes with pure virtual functions
An abstract class is specified by introducing at least one abstract method (that is, a pure virtual function prototype) in the class definition. The OO concept of an abstract method is the specification of an operation with only its protocol for usage (that is, with only the name and signature of the member function), but with no definition for the function. An abstract method will be polymorphic, in that, having no definition, it is expected to be redefined by derived classes.
A pure virtual function is used to implement the OO concept of an abstract method in C++. A pure virtual function is specified by a member function whose prototype contains =0
after the arguments to the function. Additionally, it is important to understand the following nuances regarding pure virtual functions:
- Usually, definitions for pure virtual functions are not provided. This equates to the operation (prototype only) being specified at...