advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
In recent years, there have been several proposals to add the keyword finally to standard C++. Considering the inherent differences between Java and C++'s object models, as well as the ability to use destructors for deterministic cleanup code (as shown in this solution), do you think that the C++ standards committee should reject these proposals? Let us know in our C++ Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3.5/5 | Rate this item | 6 users have rated this item.
 

Use Local Classes for Proper Cleanup in Exception-enabled Apps

While exceptions help with code reliability and data integrity, they can also complicate it. Proper cleanup is essential to making sure that your data is safe and that resources are always released. Learn how to use a local class's destructor to ensure the unconditional execution of cleanup code.  


advertisement
Exceptions enable you to detect and handle anomalous runtime conditions promptly. However, they also complicate the design of your program as they increase the number of possible execution paths. In most cases, implementing the "resource acquisition is initialization" idiom guarantees that data isn't destroyed and that resources are always released. However, this idiom isn't always an ideal solution. The following sections present a more refined technique for ensuring proper cleanup in an exception-enabled environment.



How do you ensure that critical cleanup code always executes regardless of whether an exception has occurred?


Use a local class's destructor to ensure the unconditional execution of cleanup code.

  Next Page: Demonstrating the Problem


Page 1: IntroductionPage 3: A Synergic Combination
Page 2: Demonstrating the Problem 
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs