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?
What does Is-Implemented-In-Terms-Of mean?
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 classU
, the two main options are to inherit privately fromU
or to contain aU
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.