October 1997
Intermediate to advanced
800 pages
20h 48m
English
Many applications acquire and release resources (free store memory, files, etc.) with class objects. How do we prevent resource leaks when exceptions occur? This section explores techniques that help manage resources during exception handling. We'll also discuss strategies for throwing exceptions from constructors and destructors. These techniques will improve the designs of your systems and make them more robust with exceptions.
Using operator new with classes that throw exceptions requires more discipline than using operator new with classes that don't throw exceptions. Consider instantiating a Dbase object, for instance, that throws DbaseError exceptions (see Listing 13.7 on page 616).
try { Dbase ...