摘要: 最近学习C++11,看到了强大的shared_ptr,心想,为何有了shared_ptr,还需要weak_ptr,weak_ptr是做什么的呢?经过探索,看到原因是shared_ptr内部也是基于引用计数的,引用计数的问题在于循环引用时,由于无法将计数值降为0而可能无法析构,示例如下:View Code #include "stdafx.h"using namespace std;struct Linker{ shared_ptr<Linker> link;};void DoWork(){ shared_ptr<Linker> l1(new Link 阅读全文
posted @ 2013-05-11 00:11 .NET骚操作 阅读(344) 评论(0) 推荐(1) 编辑