开发者

Dynamic memory allocation - default-initialization of primitive types in c++

If I allocate an array of some primitive type e.g.

double *v = new double[10];

I need to know, what the inital value of the array entries will be.

Is it specified in the standard or compiler dependend and where can I find it.

开发者_如何学GoThanks, Johannes


No, the array contents are not initialized. You need to use double *v = new double[10](); to have the default value of 0 for each element (Notice ()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜