Chapter 23. Exception-Safe Class Design, Part 2: Inheritance

Difficulty: 6

What does Is-Implemented-In-Terms-Of mean? It may surprise you to learn there are definite exception-safety consequences when choosing between inheritance and delegation. Can you spot them?

  1. What does Is-Implemented-In-Terms-Of mean?

  2. In C++, Is-Implemented-In-Terms-Of can be expressed by either nonpublic inheritance or by containment/delegation. That is, when writing a class T that is implemented in terms of a class U, the two main options are to inherit privately from U or to contain a U member object.

    Does the choice between these techniques have exception safety implications? Explain. (Ignore any issues not related to exception safety.)

Solution

Is-Implemented-In-Terms-Of

Get More Exceptional C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.