然后收集了关于auto_ptr的几种注意事项: 1、auto_ptr不能共享所有权。 2、auto_ptr不能指向数组 3、auto_ptr不能作为容器的成员。 4、不能通过赋值操作来初始化auto_ptr std::auto_ptr<int> p(new int(42)); //OK std::auto_ptr<int> p = new int(42); //ERROR 这是因为auto_ptr 的构造函数被定义为了explicit 5、不要把auto_ptr放入容器 这个指针已经被丢弃了!C++ Primer Plus 第6版 中文版 清晰有书签PDF+源代码 http://www.linuxidc.com/Linux/2014-05/101227.htm读C++ Primer 之构造函数陷阱 http://www.linuxidc.com/Linux/2011-08/40176.htm读C++ Primer 之智能指针 http://www.linuxidc.com/Linux/2011-08/40177.htm读C++ Primer 之句柄类 http://www.linuxidc.com/Linux/2011-08/40175.htm本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-07/104076.htm