Anything allocated with new or malloc is not "deleted" by the compiler. It needs to be cleaned up with "delete", "free", or you can just let it happen when the program exits. However, if the program runs for a while, more and more memory may continue to be allocated and eventually you'll run out of it, causing the program to crash. The only memory the compiler cleans up automatically is the stack, which you can use to efficiently allocate any variable:
{
CString s = "allocated on the stack so it will be free automatically";
CString* p = new CString("allocated on the heap, needs to be freed with delete");
delete p; // p must be cleaned up explicitly
} // s is automatically cleaned up here
Regards, Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com