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. |
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?...
|
|||||||
|
|||
|
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? |
| Sponsored Links |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
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 |