Item 13: Use objects to manage resources.(Effective C++)
To prevent resource leaks, use RAII objects that acquire resources in their constructors and release them in their destructors.
Two commonly useful RAII classes are TR1::shared_ptr and auto_ptr. tr1::shared_ptr is usually the better choice, because its behavior when copied is intuitive. Copying an auto_ptr sets it to null.