web analytics

new int(10) vs. new int[10] in C++

Options

davegate 143 - 921
@2015-12-23 09:57:53

In C++, it is always confused between the initialization of a pointer to array and a pointer to a single variable, for example:

int *ip = new int(10);

ip points to a single integer initialized with the value 10.

int *ip = new int[10];

ip points to an array of 10 integers. 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com