Deleting a pointer | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Deleting a pointer

When deleting a pointer does it have to be set to "NULL" before the delete?

23rd Nov 2017, 10:07 PM
acoolwinter
acoolwinter - avatar
2 Réponses
+ 13
To add to Jamie's answer. We set it to null after deleting the pointer to prevent accidentally referencing the now empty memory location.
24th Nov 2017, 12:14 AM
jay
jay - avatar
+ 1
A pointer is supposed to point to an object. Settibg it to Nul would be, well, pointless
23rd Nov 2017, 11:51 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar