+ 2

How to destroy an pointer?

26th Dec 2016, 12:43 AM
Elegis Sossou
Elegis Sossou - avatar
4 Respuestas
+ 2
It should be the other way round because you would reallocate your pointer and delete nothing which does not free the space you saved for p. In my way you dislocate the memory, which frees it then you reset the address stored in the pointer.
26th Dec 2016, 12:52 AM
Andreas K
Andreas K - avatar
+ 2
understand
26th Dec 2016, 12:55 AM
Elegis Sossou
Elegis Sossou - avatar
+ 1
The code is delete pointerName; pointername = NULL;
26th Dec 2016, 12:46 AM
Andreas K
Andreas K - avatar
+ 1
So int *p = NULL; delete p;
26th Dec 2016, 12:49 AM
Elegis Sossou
Elegis Sossou - avatar