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
Study the given hierarchical class diagram and additional information, and answer the questions that follow: Sale Company: string unitPrice: double

Project Description: 1) Develop banking software 2) Payment Gateway System There is some other system available for development. I'm willing to show long-term opportunity

Objectives: The objective of this assignment is to use C++ to queue students into an array-based queue for BCS registration. Students have the option of taking five different cours

Write a programme to display the patern.. A A B A C B A B C A B A A

write a class player that contain attributes for the player,s name,average and team

Explain protected, public, private in C++? These are three access spaecifiers in C++. - Public - Here data members and functions are accessible outside the class. - Pr

write an algorithm that reads a postive integer n and then finds and prints the sum of all integers between 1 and n (inclusive) that are disvisible by 7. please write this using c

Car Rental System This system tracks cars in a rental company. Each car has a number (assume its plate number), type (small car, four wheel car), and status (rented, available). T

Explain The Type Conversion in Expressions in c language? When variables and constants of different types are used in an expression they are all converted to same type. The com

Introduction to Classes Object-oriented programming (OOP) is a conceptual approach to design programs. It can be executed in many languages, whether they directly support OOP c