Delete or Destroy?
-
Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class. //OPTION 1 CLadder* pLD; pLD = new CLadder: ... ... ... delete pLD; //OPTION 2 CLadder* pLD; pLD = new CLadder: ... ... ... pLD->DestroyWindow();
-
Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class. //OPTION 1 CLadder* pLD; pLD = new CLadder: ... ... ... delete pLD; //OPTION 2 CLadder* pLD; pLD = new CLadder: ... ... ... pLD->DestroyWindow();
-
Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class. //OPTION 1 CLadder* pLD; pLD = new CLadder: ... ... ... delete pLD; //OPTION 2 CLadder* pLD; pLD = new CLadder: ... ... ... pLD->DestroyWindow();
It's my understanding that DestroyWindow really just destroy's the HWND (releases the window handle). The window object should still be intact. It's very handy to step into that code with the debugger.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
-
Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class. //OPTION 1 CLadder* pLD; pLD = new CLadder: ... ... ... delete pLD; //OPTION 2 CLadder* pLD; pLD = new CLadder: ... ... ... pLD->DestroyWindow();
DestroyWindow
is the counterpart toCreate
and is about the windows-window, the thing you see on screen.delete
is the counterpart ofnew
and is about C++ classes and memory management.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency"