3.4. Object Lessons
In the preceding section we solved a perplexing storage and transmittal problem by introducing the abstract Query base class, from which the other query types inherit. For example, when declared as a Query object, the NotQuery operand is able to address all the derived query types—not only those we know about, but also any that are introduced in the future. This solves our transmittal problem as well. Each function parameter, if declared a Query type, can now correctly pass an object of any derived query type.
In this section we look at a similar problem—except that this one relates not to independent classes, but to independent class hierarchies. So far in this chapter we have defined two class hierarchies: the LibMat and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access