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

Public inheritance makes derived types a subtype of their base. Standard conversions apply from derived objects to base objects with pointers and references (see Table 6.5, “Standard conversions,” on page 277). This means derived object references or pointers may appear in expressions whose types are base object references or pointers.

The compiler converts derived class pointers and references to base class pointers and references implicitly (without casts). These standard conversions occur with object initialization, assignment, and function argument resolution. Here are several examples.

 class Derived : public Base { . . . }; Base b; // Base object Derived d; // Derived publicly from Base Base *bp = &d; // legal, pointer standard ...

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