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;
}

posted @ 2013-07-06 12:37  Predator  阅读(982)  评论(0编辑  收藏  举报