普通指针与share_ptr的互相转换:

struct test
{
	int num;
	string name;
};

test* pTest = new test();
std::shared_ptr<test> ptr_test = std::shared_ptr<test>(pTest); //普通指针转shared_ptr
	
std::shared_ptr<test> ptr_test2 = std::make_shared<test>();
test* pTest2 = ptr_test2.get(); //shared_ptr转普通指针

  

相关文章:

  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-08-04
  • 2021-06-10
猜你喜欢
  • 2022-02-19
  • 2021-10-10
  • 2022-01-21
  • 2021-06-02
  • 2021-07-18
相关资源
相似解决方案