December 2001
Intermediate to advanced
304 pages
6h 25m
English
Difficulty: 4
What exactly happens when a constructor emits an exception? What if the exception comes from an attempt to construct a subobject or member object?
Consider the following class:
// Example 17-1
//
class C : private A
{
B b_;
};
In the C constructor, how can you catch an exception thrown from the constructor of a base subobject (such as A) or a member object (such as b_)?
Consider the following code:
// Example 17-2
//
{
Parrot p;
}
When does the object's lifetime begin? When does it end? Outside the object's lifetime, what is the status of the object? Finally, what would it mean if the constructor threw an exception?
Function try blocks were added to C++ to slightly enlarge ...
Read now
Unlock full access