2013年11月14日

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) 编辑

g++版本低于4.7使用C++11

摘要: 编译时需要添加:需要添加头文件#includeg++ -std=gnu++0x share_ptr.cpp -o s原文:C++11 features are available as part of the "mainline" GCC compiler in the trunk ofGCC's Subversion repositoryand in GCC 4.3 and later. To enable C++0x support, add the command-line parameter-std=c++0xto yourg++command line. 阅读全文

posted @ 2013-11-14 21:46 Practicer.. 阅读(1042) 评论(0) 推荐(0) 编辑

导航