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

12.4. RTTI Applications

This section examines several applications with RTTI. We'll show you how RTTI determines object types in class hierarchies, extends class libraries for new classes, and controls object behaviors. These applications demonstrate the power of RTTI and its important role as a portable solution to class library design.

Working with Class Hierarchies

This example applies RTTI to the Shape class hierarchy from Chapter 11 (Listing 11.23 on page 531). We'll start with the Shape abstract base class.

Listing 12.1. Abstract class Shape interface
 class Shape { // abstract base private: static int count; // static data member public: Shape() { count++; } // constructor Shape(const Shape &) { count++; } // copy constructor virtual ~Shape() ...

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