Ray's playground

 

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.

  • posted on 2010-01-05 22:09  Ray Z  阅读(172)  评论(0编辑  收藏  举报

    导航