I like to go one step further. After all of that I set the pointer to null, so if I try and access it later accidently the program will fault. I usually just make a macro for this.Quote:
Originally posted by Sebastiani
BTW, never do:
delete x;
Instead,
if(x) //...or if you like, if(x != NULL)
delete x;
This will ensure that you don't crash the proggie from deleting a NULL pointer...
Code:#define SafeDelete( x ) if( x ) delete x, x = NULL;