O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required