复制RAII对象必须一并复制它所管理的资源,所以资源的copying行为决定RAII对象的copying行为. 普遍而常见的RAII class copying行为是:抑制copying(使用私有继承Uncopyable).施行引用计数法(reference counting)(即std::tr1::shared_ptr,可以自己指定删除器).不过其他行为也都可能被实现.…
In C++, the only code that guaranteed to be executed after an exception is thrown are the destructors of objects residing in stack and that's why we need RAII. We don't always deal with head based objects, so instead with using auto_ptrs and shared_p…