Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Exception Thrown in Destructor

This is a discussion on Exception Thrown in Destructor within the C and C++ forums, part of the Software Development category; Can we thrown the exception in the destructor? If yes then please tell me after exception thrown what will happen with the object. Object is deleted or not?...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 10-13-2009
Junior Member
 
Join Date: Mar 2007
Location: India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ashishsaryar is on a distinguished road
Exception Thrown in Destructor

Can we thrown the exception in the destructor?

If yes then please tell me after exception thrown what will happen with the object.

Object is deleted or not?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-14-2009
Expert Member
 
Join Date: May 2009
Location: Bangalore
Posts: 989
Thanks: 155
Thanked 420 Times in 201 Posts
rijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nice
Re: Exception Thrown in Destructor

Hi,

Yes. It is legal to call a function that may throw an exception inside a destructor. However, it is important to handle any exception that might be thrown from such a function inside the destructor body.

But throwing an exception out of a destructor is dangerous.

Once a destructor is invoked for an object, the object no longer exists; the behavior is undefined if the destructor is invoked for an object whose lifetime has ended.

Thanks,
Rijus.
-----------------------------------------
Real Inspirational Journey.........Unanimously & Sincerely.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Related to sequence of call of destructor ashishsaryar C and C++ 1 06-25-2009 07:46 AM
constructor & destructor Molugu Natraj C and C++ 6 05-10-2009 09:41 AM
constructor and destructor Sangeetha Poojary C and C++ 8 04-06-2009 01:47 PM
Can a structure in C++ have a Constructor and Destructor coolsomoo C and C++ 2 02-02-2009 07:45 AM
Can child class be compiled when it has thrown sql exception james345 Java 1 08-30-2007 07:27 AM


All times are GMT -4. The time now is 06:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved