More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions

I l @ ve RuBoard

Difficulty: 7

This Item analyzes constructor failures in detail, shows why the C++ rules should work the way they do, and demonstrates the implications for constructor exception specifications.

  1. In Item 17 Example 17-1, if the A or B constructor throws an exception, is it possible for the C constructor to absorb the exception and emit no exception at all? Justify your answer, explaining by example why this is as it should be.

  2. What are the minimal requirements that A and B must meet in order for us to safely put an empty throw-specification on C 's constructor(s)?

I l @ ve RuBoard

Категории