Item 18. Constructor Failures, Part 2: Absorption?

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


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net