What does “new int(100)” do?

The first line allocates a single int and initializes it to 100. Think of the int(100) as a constructor call.

Since this is a scalar allocation, trying to access arr[1] or to free the memory using delete[] would lead to undefined behaviour.

Leave a Comment