The problem is CMainFrame * pFrame=new CMainFrame; This way, the final end of the program prompt memory leaks, error point is this way, But I have been added in the CMainFrame kind PostNcDestroy delete this, and it has executed, Void CMainFrame: : PostNcDestroy () { Delete this. }
Excuse me each Daniel, why would an error memory leak? Thank you for advice
CodePudding user response:
PFrame=new CMainFrame; Is a with the original structure CMainFrame (namely pFrame - & gt; LoadFrame (no IDR_MAINFRAME,) Frame
CodePudding user response:
Constructed two MainWnd, delete a, there is another
CodePudding user response:
MFC framework in the window after Destroy the default will be called CFrameWnd: : PostNcDestroy () function, the function will be called the delete this; To delete a pointer, you can don't have to override the virtual function, If your framework class pointer is not allocated by means of the new words, such as the definition not a class member function, then you need to override the virtual function to modify its implementation, and then call the delete this will certainly lead to abnormal program,