How can I make `new[]` default-initialize the array of primitive types?

int* p = new int[10]() should do.

However, as Michael points out, using std::vector would be better.

Leave a Comment