int* func()
{
int* i=new int[1];
//do something
return i;
}
void funcc()
{
int* tmp=func();
//delete allocated memory after use
delete tmp;
}
Run Code Online (Sandbox Code Playgroud)
应该删除第二个功能中描述的工作是否正确使用?我想我没有为新分配内存?第一次使用new,可以肯定.