Constructors in Multiple-Inheritance Hierarchies with virtual Base Classes

Implementing hierarchies with virtual base classes is simpler if default constructors are used for the base classes. Figures 21.13 and 21.14 use compiler-generated default constructors. If a virtual base class provides a constructor that requires arguments, the derived-class implementations become more complicated, because the most derived class must explicitly invoke the virtual base class’s constructor. Providing a default constructor for virtual base classes simplifies hierarchy design.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.