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
Problem : (a) What do you understand by the term ‘constructor' in Java? Explain with an appropriate example. (b) Describe the differences between an object and a class usi

Unions A union is also like a structure, except that only single variable in the union is stored in the allocated memory at a time. It is a collection of mutually exclusive var

find area uder the curve y=f(x) between x=a and x=b   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; in

We move a high quantity of large Video files (200mb - 2 GB each) across the internet. We have a Linux server (ubuntu) hosted in a datacenter (1Gbps) operating an FTP server. Our

Define External Static Storage Class - Computer Programming? An external static is declared outside of all the functions and is obtainable to all functions in that program. The

can you tell me what is c#

#question.conversion of tree into binary tree.

Define some Important Point for bit fields with structures? Only n lower bits will be assigned to an n bit number thus type cannot take values larger than 15 (4 bits long)

Destructors A destructor function gets implemented whenever an instance of the class to which it belongs goes out of existence. The primary usage of a destructor function is

Homework – Chapter 5 – Bowling Scores 33. Write a complete C++ program to do the following: The main program reads in and prints three bowling scores, score1, score2, and score