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 ()
).
精彩评论