Hi guys! What is the corrext way to handle exceptions during construction of a member object?
A code snippet is give below:
As you can see from the code above, class A gets constructed first whenever class B is instantiated. So what is the correct way for class B to handle the exception thrown by class A?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -
A code snippet is give below:
Code:
class SomeException {};
class A
{
public:
A() throw(SomeException)
{
if(...)
{
throw SomeException();
}
}
};
class B
{
public:
...
private:
A the_a;
};
int main(int argc, char* argv[])
{
B the_b; // suppose class A has thrown an exception
// during class B's construction.
}
As you can see from the code above, class A gets constructed first whenever class B is instantiated. So what is the correct way for class B to handle the exception thrown by class A?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -