Google News
logo
CPP - Interview Questions
What do you mean by Stack unwinding?
Stack Unwinding happens during exception handling. During an exception occurrence, the destructor is called to destroy all local objects for the place where the exception was thrown and where it was caught. An exception causes the control to pass on from a try block to the respective exception handler.  The destructors for all constructed automatic objects are called at run time which where created since the beginning of the try block. The automatic objects are destroyed in reverse order of their construction.
 
Note : The corresponding objects must be created before destruction of the same which takes place during Stack Unwinding.
 
The terminate() function is invoked during Stack Unwinding on a destructor for a unhandled exception.
 
 
Advertisement