C++ 智能指针make_share

#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
using namespace boost;
using namespace std;

void main()
{
boost::shared_ptr<int> p = boost::make_shared<int>(14);
cout << p.use_count() << " " << *p << endl;

/*************************输出结果*********************************************
*1 14
*2 2 14 14
*2 2 10000 10000
******************************************************************************/
boost::shared_ptr<int>other = p;
cout << p.use_count() << " " << other.use_count() << " " << *p << " " << *other << endl;

*other = 10000;
cout << p.use_count() << " " << other.use_count() << " " << *p << " " << *other << endl;

 

int wait;
cin >> wait;
}

原文链接: https://www.cnblogs.com/ganquanfu2008/p/3175018.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++ 智能指针make_share

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/94812

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月10日 上午2:48
下一篇 2023年2月10日 上午2:49

相关推荐