【发布时间】:2011-06-23 22:19:12
【问题描述】:
我正在查看 new 运算符的签名。即:
void* operator new (std::size_t size) throw (std::bad_alloc);
但是当我们使用这个操作符时,我们从不使用强制转换。即
int *arr = new int;
那么,在这种情况下,C++ 如何将void* 类型的指针转换为int*。因为,即使malloc 返回void*,我们也需要显式使用强制转换。
【问题讨论】:
标签: c++ memory-management new-operator operator-keyword dynamic-memory-allocation