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.5. Putting It All Together

RTTI Implementation

The implementation of RTTI is compiler dependent, but let's look at a typical configuration. To illustrate, consider the following Base and Derived class definitions.

class Base { 
private:
   // Base members
public:
   Base() { }
   virtual void f1() { cout << "Base::f1()" << endl; }
   virtual void f2() { cout << "Base::f2()" << endl; }
   virtual void f3() { cout << "Base::f3()" << endl; }
};
class Derived : public Base {
private:
   // Derived members
public:
   Derived() { }
   void f2() { cout << "Derived::f2()" << endl; }
   virtual void f4() { cout << "Derived::f4()" << endl; }
};

Base defines three virtual functions. Derived overrides f2() and defines virtual function f4(). Suppose we declare the following objects. ...

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