October 1997
Intermediate to advanced
800 pages
20h 48m
English
A model that generalizes attributes and behaviors into a single base class that you never instantiate is a good design approach with many problem domains. An example might be a Rental_Property class from which we derive House, Apartment_Building, and Office_Building. We never create a Rental_Property object; instead, we instantiate derived objects that specify a property type. Another example is a Shape class from which we derive Circle, RTriangle (right triangle), and Square. An unspecialized Shape object can never exist because we must specify a Shape type before we use it.
Let's explore this concept further with a Shape hierarchy that manipulates two-dimensional shapes. We'd like to determine the area and perimeter ...