【发布时间】:2015-04-11 20:49:12
【问题描述】:
我对在 c++ 中分配数组的 new 运算符有疑问:
int * foo;
foo = new int [5];
在这种情况下,foo 指向一个 int 数组,但是如何将代码更改为:
foo = new int [0];
分配了什么,会发生什么?
【问题讨论】:
标签: c++ arrays new-operator dynamic-memory-allocation
我对在 c++ 中分配数组的 new 运算符有疑问:
int * foo;
foo = new int [5];
在这种情况下,foo 指向一个 int 数组,但是如何将代码更改为:
foo = new int [0];
分配了什么,会发生什么?
【问题讨论】:
标签: c++ arrays new-operator dynamic-memory-allocation
没有分配任何东西,使用该指针将调用未定义的行为。
【讨论】: