O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

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

Inheritance and Polymorphism

Another feature of object-oriented programming is the ability to reuse class definitions in order to simplify the creation of new classes. In other words, you can create more specialized versions of classes to deal with new types of object.

Because these derived classes share a number of features with existing classes, it makes sense to just extend the base, or parent class, rather than cut and paste the code into a completely new class. Added to this, if you change the underlying functionality of the base class, it is reflected in any classes that inherit from it.

There are a few points to remember when designing a class for inheritance:

  • Assignment operators are not inherited.

  • Constructors are not inherited.

  • Private ...

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