MFC does a lot with new and delete to allow it to do things like allocation
tracking and memory leak detection; however, it does nothing to relieve the
responsibility of deallocating (i.e., delete-ing) the memory you allocate
with new.
What you are seeing with the CMainFrame object is a C++ trick, not an MFC
trick. You will also see that the pointer to the new CMainFrame object is
stored in a member variable of the CWinApp-derived class. When the
application shutdown, cleanup code in the CWinApp class deletes this
pointer.
Dave Smith
Quote:
> Is there anything special about the way MFC treats new/delete pairing
> please?
> IE if my code does a new somewhere I assume I **must** do the
> corresponding delete as well to release the memory allocated?
> Only if you look at a typical MFC wizard generated program yo see a line
> like this:
> CMainFrame* pFrame = new CMainFrame;
> in InitInstance but no delete for it.
> I assume that MFC knows about this and tidies up?