相关疑难解决方法(0)

auto_ptr是否已被弃用?

  1. 在传入的C++标准中是否会弃用auto_ptr?
  2. unique_ptr应该用于所有权转移而不是shared_ptr吗?
  3. 如果unique_ptr不在标准中,那么我是否需要使用shared_ptr?

c++ standards smart-pointers auto-ptr unique-ptr

77
推荐指数
3
解决办法
4万
查看次数

new运算符是否会返回NULL?

可能重复:
在任何情况下new都会返回NULL吗?

说我有一个类Car,我创建一个对象

Car *newcar  = new Car();
if(newcar==NULL) //is it valid to check for NULL if new runs out of memory
{
}
Run Code Online (Sandbox Code Playgroud)

c++ new-operator

18
推荐指数
2
解决办法
2万
查看次数