3 ms·
>Now consider what happens when you add inheritance to the mix. C++ allows to initialise base classes as a part of >derived class' constructor. Throwing an exce
by signa11 15y ago
>Now consider what happens when you add inheritance to the mix. C++ allows to initialise base classes as a part of >derived class' constructor. Throwing an exception will destruct the parts of the object that were already successfully initialized with this
which object is he talking about here ? if foo inherits from bar, object foo is not considered a valid object till it's constructor completes. so there is no question of destroying parts of objects which were already constructed.
similarly, during object destruction, as soon as the destructor is invoked, the object is in an invalid state.
i guess there are some issues in understanding of object lifetimes and exceptions thrown by it's constructors...