I am well aware of the fact that one should not throw any exception in destructor.
But as a part of making my grip on this concept,I coded this example :-
In your example, A()
construct a temporary variable for A
then destructs it immediately. Thus throw 10;
is never executed.
The throw
statement taking place is in the destructor for A
. When executing A::~A()
, the program is not unwinding (i.e. cleaning up state from an exception) at that point. See "Destructors that throw" for example.