Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date