C++ std::shared_ptr的使用
普通指针与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转普通指针