0

what is the difference between these two: 1)int* p = new int[5]; 2)int* p = new int(5);

17th Sep 2016, 4:23 AM
fdfasd
3 Réponses
+ 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
17th Sep 2016, 5:44 AM
Igor Duran
Igor Duran - avatar
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.
21st Oct 2016, 9:16 PM
PANKAJ KUMAR
PANKAJ KUMAR - avatar
0
https://stackoverflow.com/questions/13797926/what-does-new-int100-do see Peopleware's answer. It might the second one.
23rd Nov 2018, 8:59 AM
Abhijit Mohapatra
Abhijit Mohapatra - avatar