O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

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

11.11. Abstract Base Classes

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

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