C++ boost的share_ptr传递给普通指针,修改原来的值

#include<iostream>
#include "common.h"
#include<string>
#include <ctype.h>
#include "Calendar.h"
#include <iostream>
#include<boost/date_time.hpp>
#include <boost/lexical_cast.hpp>
using namespace boost::posix_time;
using namespace boost::gregorian;
using namespace std;
 
 
struct tagPerson
{
	string name;
	int age;
}Person;
 
 
 
void ChangeContentBySP(tagPerson *person);
int main(int argc)
{	
 
 
 
	boost::shared_ptr<tagPerson> myPerson(new tagPerson());
	myPerson->name = "ganquanfu";
	myPerson->age = 29;
	ChangeContentBySP(myPerson.get());
	cout << myPerson->name << "   " << myPerson->age << endl; //输出000000000  28
 
	int wait;
	cin >> wait;
 
	return 0;
}
 
void ChangeContentBySP(tagPerson *person)
{
	person->name = "000000000";
	person->age = 28;
 
}
 

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

欢迎关注

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

    C++ boost的share_ptr传递给普通指针,修改原来的值

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

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

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

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

(0)
上一篇 2023年2月10日 上午3:47
下一篇 2023年2月10日 上午3:47

相关推荐