The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
call constructor of java class in script thebladerunner Shell Programming and Scripting 1 10-21-2008 12:23 PM
Linguistic Tree Constructor 2.8.0 (Default branch) iBot Software Releases - RSS News 0 01-27-2008 07:30 PM
what is diff b/w copy constructor and overloaded assignment operator amitpansuria High Level Programming 3 08-06-2007 12:45 PM
why constructor cannot be virtual amitpansuria High Level Programming 2 08-03-2007 12:02 AM
Constructor problem woot4moo UNIX for Dummies Questions & Answers 4 09-05-2006 10:49 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-07-2007
Registered User
 

Join Date: Jul 2007
Posts: 91
how do you handle a constructor and destructor that fail

helo i m new in c++ on linux
can u tell me with an simple example that how do you handle constructor and destructor that fail?
Regards,
Amit
Reply With Quote
Forum Sponsor
  #2  
Old 08-07-2007
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,477
What do you mean by fail? Throwing exception? Access violation? C++ has try/catch for handling non-fatal program-driven exceptions. Or were you actually looking for something else?
Reply With Quote
  #3  
Old 08-07-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by amitpansuria View Post
helo i m new in c++ on linux
can u tell me with an simple example that how do you handle constructor and destructor that fail?
I was under the impression that the only things you should put in constructors/destructors were things that would not fail (or else you deal with the exceptions inside the constructor/destructor).
Reply With Quote
  #4  
Old 08-15-2007
Registered User
 

Join Date: Jul 2007
Posts: 91
never throw an exception from the destructor that fails?

Quote:
Originally Posted by porter View Post
I was under the impression that the only things you should put in constructors/destructors were things that would not fail (or else you deal with the exceptions inside the constructor/destructor).
can u explain me step by step why exception is not thrown from the destructor that fails with an example
Regards,
Amit
Reply With Quote
  #5  
Old 08-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by amitpansuria View Post
can u explain me step by step why exception is not thrown from the destructor that fails with an example
Regards,
Amit
No, I'm saying that you shouldn't have code in your destructor that can fail.

If you can't achieve that then you handle then use try/catch in your destructor around the part that may fail.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0