Chapter 15. Writing Exception-Safe Code—Part 8
Difficulty: 9
That's it—this is the final leg of the miniseries. The end of the line is a good place to stop and reflect, and that's just what we'll do for these last three problems.
Which technique is better—using
StackImpl
as a private base class, or as a member object?How reusable are the last two versions of
Stack
? What requirements do they put onT
, the contained type? (In other words, what kinds ofT
can our latestStack
accept? The fewer the requirements are, the more reusableStack
will be.)Should
Stack
provide exception specifications on its functions?
Solution
Let's answer the questions one at ...
Get Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions 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.