0
what is the difference between these two: 1)int* p = new int[5]; 2)int* p = new int(5);
3 Antworten
+ 1
for none, since both are badly declared.
In managing pointers as to the dynamic memory you can also be assigned to the arrays.
taking the example of the course.
int * p = NULL; // Null pointer initialised
p = new int [20]; // Application Memory
delete [] p; // Remove array pointed to by p
0
1) here we are dynamically allocating memory for array of 5 integer . each of these are initialized to 0.
2) here we are dynamically allocating memory for an integer which is initialized to 5.
0
https://stackoverflow.com/questions/13797926/what-does-new-int100-do
see Peopleware's answer. It might the second one.