![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BOOST
afrish
一步一步开始,学习一路漫长
展开
-
智能指针 boost(scoped_ptr,scoped_array,shared_ptr,shared_array) 和 std (auto_ptr)的比较
1、std::auto_ptrstd::auto_ptr相信都接触使用过,对于一般的用户它绝对够用了,new一块内存自动释放 例如:int main(){ std::auto_ptr p(new int); return 0;} 但它的不足之处在与,对象拥有者只有一个,换句话说:就是new出来的内存空间只属于一个对象 例如:int m原创 2009-03-12 22:09:00 · 1600 阅读 · 0 评论 -
Boost智能指针——weak_ptr
Boost智能指针——weak_ptr 循环引用: 引用计数是一种便利的内存管理机制,但它有一个很大的缺点,那就是不能管理循环引用的对象。一个简单的例子如下: #include #include #include #include class parent;class children;typedef boost::shared_ptr parent_ptr;typedef boost转载 2009-03-12 22:58:00 · 1516 阅读 · 1 评论