c++ 栈上分配的对象转智能指针

 class Test
{
public:
  Test() {}
  int implAdd(int a, int b) { return a ^ b; }
};

typedef std::shared_ptr<Test> Test_ptr;
Test_ptr ff_ptr(new Test(std::move(ff)));
ff.implAdd(2,2);

 

posted @ 2022-07-18 10:45  Ray.floyd  阅读(109)  评论(0编辑  收藏  举报