摘要: C++堆内存管理 auto_ptr的缺陷 在很早的C++98之前,C++用"auto_ptr"智能指针来管理堆分配的内存,它的使用非常简单: auto_ptr ap(new int(1024)); 即将new操作返回的指针作为auto_ptr的初始值,不用调用delete即可实现堆内存的自动释放(如析构的时候)。 由于auto_ptr本身存在一些问题,它在C++11中被抛弃了。例如 1. a... 阅读全文
posted @ 2017-07-12 14:05 wfjiang 阅读(1456) 评论(0) 推荐(0) 编辑