TITLE: Throwing exceptions in destructors PROBLEM: iis@netcom.com (International Imaging Syste) 3. Avoid calling a class's destructor inappropriately when throwing and catching one of these exceptions. RESPONSE: rmartin@rcmcon.com (Robert Martin), 29 May 93 There is an issue related to destructors that the programmer will have to be a bit careful about. If an exception is thrown within a destructor which has been called during the stack rollback caused by a different exception, then the exception mechanism breaks down and the "terminate()" function is called. You can supply your own "terminate" function, but it cannot return, it must lead to the termination of the program. (At least this is what the ARM says on p364.) So, one must be very careful when throwing exceptions in destructors. This becomes an issue when using the "resource acquisition is initialization" idiom for opening and closing files. The destructor of such an acquisition object will close a file. If an error occurs during the file close, an exception may be thrown. Question: If the destructor catches an exception thrown by a function that it calls, and if this destructor is called during the stack unwinding of a previous exception, will "terminate" be called or will the exceptions nest?