智能指针
来源:互联网 发布:江宁淳化网络问政 编辑:程序博客网 时间:2024/04/27 01:44
http://en.wikipedia.org/wiki/Auto_ptr && 《c++ primer》17.1.9
1 In the upcoming c++0x, auto_ptr will be deprecated;
2 auto_ptr之间的拷贝回导致source失去所指向对象的reference,因为同一指针智能被一个auto_ptr所拥有;
3 auto_ptr使用delete销毁拥有的指针,因此他拥有的指针只能使用new来分配空间。malloc,calloc,realloc分配的指针不能使用,array也不可以,使用的是new[]。
《more effective c++》
item10, 智能指针能用来解决在构造函数中发生异常导致的内存泄露问题;
shared_ptr
http://www.cppprog.com/boost_doc/libs/smart_ptr/shared_ptr.htm
1 能够用于stl库;
2 单个对象使用shared_ptr, 动态数组使用shared_array;
3 best practises
3.1 一个简单的近乎完全消灭内存泄露的方针,总是使用一个已命名的智能指针接收new的结果;
3.2 不要使用匿名的shared_ptr临时变量存储内容,可能造成内存泄露。
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- 智能指针
- HEY
- 关于DCMTK中findscu.exe使用的一些问题
- SQL Server连接中的三个最常见错误:
- 【转】MySQL 建表的优化策略 小结
- 静态链接库(Lib)与动态链接库(DLL)的区别
- 智能指针
- JSF 标签h:panelGrid
- 最大似然估计(maximum likelihood)
- SCP的一些记录
- hibernate 一对一、多对一 双向关联的问题——只能在多的一方添加、修改数据,不能在多的一方修改添加
- 斯德哥尔摩综合症
- programming languages are not just tools
- 学习笔记---listbox和listview
- EM算法(expection maximization)