Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Delete or Destroy?

Delete or Destroy?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oliver123
    wrote on last edited by
    #1

    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();

    C P J 3 Replies Last reply
    0
    • O Oliver123

      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();

      C Offline
      C Offline
      CooperWu
      wrote on last edited by
      #2

      DestroyWindow before delete it.

      1 Reply Last reply
      0
      • O Oliver123

        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();

        P Offline
        P Offline
        Peter Weyzen
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        • O Oliver123

          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();

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          DestroyWindow is the counterpart to Create and is about the windows-window, the thing you see on screen. delete is the counterpart of new 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"

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups