对于此代码,C++中有与智能指针相同的编码?
在External.cpp中:
class ExampleClass {...};
ExampleClass* function()
{
ExampleClass *ptr = new ExampleClass();
ptr->doSomething();
return ptr;
}
Run Code Online (Sandbox Code Playgroud)
在Another.cpp中我想做这样的事情,怎么做?:
ExampleClass *ptr2 = function();
Run Code Online (Sandbox Code Playgroud)