What does () mean at the end of a dynamic array?

I have an example similar below in another question that I have not seen before.

new int[m_size](); ^^ 

I saw and used the new int[m_size] version all the time, but not the one with () at the end.

+7
source share
2 answers

Two words: Initialization of values

new int[m_size](); The elements of the array will be initialized to zero by writing () , because () implies initializing the value. 1 (zero initialization for primitive type)

1: An object whose initializer is an empty set of brackets, i.e. (), must be initialized with a value. ($ 8.5 / 7)

+12
source

this means that all elements will be zero initialized , similar to calloc(o,sizeof(int)) , where with this calloc, ur, initializing a single integer on the heap with 0

+2
source

All Articles