shared_ptr
摘要:
int *ptr=new int(1); 7 shared_ptr p1(ptr); 8 shared_ptr p2(ptr); 9 cout> vector中的元素指针设定为shared_ptr类型,这样的话,在析够vector时就不需要手动delete指针 vector> pVec;test *t=new test(1);shared_ptr t1(t);pVec.push_back(t1);pVec.push_back(shared_ptr(new test(2)));这样到函数的最后,自动调用test的析够... 阅读全文
posted @ 2013-11-14 22:48 Practicer.. 阅读(396) 评论(0) 推荐(0) 编辑