How can one handle a destructor that fails?, C/C++ Programming

How can one handle a destructor that fails?

Posted Date: 3/15/2013 5:17:15 AM | Location : United States





How can one handle a destructor that fails?

A: Write down a message to a log-_le. However do not throw an exception. The C++ rule is that you ought to never throw an exception from a destructor which is being called during the "stack unwinding" procedure of another exception. For instance, if someone says throw Foo(), the stack will be unwound so all of the stack frames among the throw Foo() and the } catch (Foo e) { will get popped. It is called stack unwinding. Throughout stack unwinding, the entire local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win condition: should it avoid the Bar and end up in the} catch (Foo e) {where it was headed originally? Should it avoid the Foo and look for a } catch (Bare) { handler? There is no good answer: either choice loses information. Thus the C++ language guarantees that it will call terminate() at this point, and terminate() kills the procedure. Bang you''re dead.

 

Posted by | Posted Date: 3/15/2013 5:17:54 AM


Related Discussions:- How can one handle a destructor that fails?, Assignment Help, Ask Question on How can one handle a destructor that fails?, Get Answer, Expert's Help, How can one handle a destructor that fails? Discussions

Write discussion on How can one handle a destructor that fails?
Your posts are moderated
Related Questions
#Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can

palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindromes

Define the Keywords of c language? C keeps a small set of keywords for its personal use. These keywords can't be used as identifiers in the program. Here is the list of keyword

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

c-program to find the area under the curve y=f(x) between x=a and x=b integrate y=f(x) between the limits of a and b   #include float start_point, /

kirchoff''s law

What does it mean to declare a 1.      member function as a virtual A: (a) C++ virtual function is member function of any class, whose functionality may be over- ridden in

Program is to find the maximum from two numbers: Program is to find the maximum from two numbers entered by the user having pointer variable as parameter void main()   {

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.