Quote:
Originally Posted by ccoonen Essentially you just want to make it Available for the Garbage Collector to come get it - like unreference it from items. If it has no references and isn't being used, then the GC can come "collect" that memory. You can also force it (GC.Collect) but generally it's enough to make it available for pickup and it will be dealt with accordingly  |
C++ hasn't got a garbage collector. perhaps you're confusing it with one of the managed microsoft languages?
to clean up memory allocated with new, use the delete keyword. If you forget to delete, this is when you get memory leaks.
Code:
//Allocating & deallocating space for a single object
int* foo = new int;
delete foo;
Code:
//Allocating & deallocating space for an array of 20 ints
int* bar = new int[20];
delete [] bar;