小编mak*_*tie的帖子

Smartpointers等效

对于此代码,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)

c++ oop smart-pointers

1
推荐指数
1
解决办法
120
查看次数

标签 统计

c++ ×1

oop ×1

smart-pointers ×1