mod_annot editor

Annotate Section

The Constructor/Destructor model

One method of resource management is exemplified by the C++ concept of objects having a constructor and destructor. A method adopted by many (but not all) C++ programmers is to make the destructor responsible for cleanup of all resources allocated by the object. This approach works well provided all dynamic resources are clearly made the responsibility of an object. But, as with the simple C approach, it requires a good deal of care and attention to detail, for example where resources are conditionally allocated, or shared between many different objects, and is vulnerable to programming bugs.