Is there a need for removing pointers after use
ptr = &c;
Marky_Mark
Is there a need for removing pointers after use
ptr = &c;
Marky_Mark
You should only have to do anything if they point to data that you've dynamically allocated using new or malloc, in which case you should call delete/free() and then point them to NULL.
zen
It depends. If you have allocated memory for that pointer using one of the following: malloc(), calloc(), realloc() or new you have to return that memory to the machine eventually - using either free() or delete.
If you don't free the memory you allocated you will wind up with a memory leak, which is a very bad thing and is hard to find.
1 rule of the Samurai Code: if you have nothing to say, don't say anything at all!
I will be using new
What's the correct syntax for freeing objects
Marky_Mark
delete [] *iPointer;
*iPointer = NULL;
"Where genius ends, madness begins."
-Estauns
It depends on how they're allocated, if you use [] with new (ie create an array), then you should use [] in the delete statement -
delete [] iPointer;
or if you create a single object then just
delete iPointer;
is required.
zen
My bad, should of clarified that.
"Where genius ends, madness begins."
-Estauns
Thanks for clearing that up
Marky_Mark