␡
- The Takeaway
- Document Management
- The Base Class: AnyOldDocument
- Economy in Coding
- The First Document Type: A Memo
- The Second Document Typean Invoice
- The Third and Last Document Typea Contract
- Leveraging Base Class Generality
- Polymorphism
- Complete Program Output
- Make Your Destructors Virtual
- Conclusion
- Additional Reading
Like this article? We recommend
Leveraging Base Class Generality
The invoice and contract classes differ only in the way they use the supplied number value. The semantics related to this number are significantly different for these two classes. However, the base class is identical for both of these classes. This is a useful method of reducing derived class code: keep the base class generic and modify the semantics in the derived classes. The base class doesn’t care!