Destructor , C/C++ Programming

How can I handle a destructor that fails? Need help please provide example also.

Posted Date: 2/13/2013 1:17:04 AM | Location : United States





Write a message to a log-_le. But do not throw an exception. The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Poo(), the stack will be unwound so all the stack frames between the throw Poo() and the } catch (Poo e) { will get popped. This is called stack unwinding. During stack unwinding, all the 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 situation: should it ignore the Bar and end up in the} catch (Poo e) { where it was originally headed? Should it ignore the Poo and look for a} catch (Bare) {handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you''re dead.

Posted by Archie | Posted Date: 2/13/2013 1:18:53 AM


Related Discussions:- Destructor , Assignment Help, Ask Question on Destructor , Get Answer, Expert's Help, Destructor Discussions

Write discussion on Destructor
Your posts are moderated
Related Questions
expression and its types with example programs

write a C rpogram that can display the transpose form of a ciphertext matrix.Prompt users to provide row and coloumn number of matrix.Then user will input plaintext and the program

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

I have to make a program that allow the user input 10 numbers between 10 and 100 and if the number input is the same than the last number, should appear an error message. I have th

There are 3 acceptable answers: "Never," "Rarely "and" When the problem domain cannot be accurately modelled any other way."

A: By keeping along with the C++ tradition of "there's more than one method to do that" (translation: "give programmers options & tradeoffs so they can choose what's best for them


There are two ways for initializes in C++ as shown in the example that follows. The first way uses the traditional C notation. The second way uses constructor notation. int foo


create algorithm for doubly link list using c data structure