Patrick Logan wrote in message ... >In comp.object Mattias Lundstr�m wrote: > >: Note also that in the case of Java this kind of resource >: cleanup may not be satisfactory since we can not know when >: the finalization (cleanup) is actually done. > >In Java you should always explicitly handle resource deallocation for >all resources that are in any way "precious". Use... > > try {} finally { deallocation } > >to ensure that deallocation will occur no later than the exit of the >"try" body. And, in C++, because destructors are not in the scope of the try block, I prefer: try {...; cleanup();} catch(...){cleanup(); throw;} Rather than trying to use destructors as a general solution. Robert C. Martin | Design Consulting | Training courses offered: Object Mentor | rmartin@oma.com | Object Oriented Design 14619 N Somerset Cr | Tel: (800) 338-6716 | C++ Green Oaks IL 60048 | Fax: (847) 918-1023 | http://www.oma.com "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan