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. Dynamic Object Creation, ok. What about destruction?

Dynamic Object Creation, ok. What about destruction?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 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.
  • M Offline
    M Offline
    Mr Freeze
    wrote on last edited by
    #1

    Hi, I created an instance of my CFrameWnd-derived class with: CRuntimeClass* pRuntimeClass=RUNTIME_CLASS(CMainWindow); CObject* pObject=pRuntimeClass->CreateObject(); ASSERT(pObject->IsKindOf(RUNTIME_CLASS(CMainWindow))); CMainWindow* mainWindow=(CMainWindow*)pObject; How can I destroy this object at the end of my application? delete mainWindow does obviously not work. Is there maybe a function similar to CreateObject() which destroys it? Thank you :)

    N 1 Reply Last reply
    0
    • M Mr Freeze

      Hi, I created an instance of my CFrameWnd-derived class with: CRuntimeClass* pRuntimeClass=RUNTIME_CLASS(CMainWindow); CObject* pObject=pRuntimeClass->CreateObject(); ASSERT(pObject->IsKindOf(RUNTIME_CLASS(CMainWindow))); CMainWindow* mainWindow=(CMainWindow*)pObject; How can I destroy this object at the end of my application? delete mainWindow does obviously not work. Is there maybe a function similar to CreateObject() which destroys it? Thank you :)

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      I am not sure what you are trying to do, but your main frame window gets destroyed when the app exits and vice versa. Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      M 1 Reply Last reply
      0
      • N Nish Nishant

        I am not sure what you are trying to do, but your main frame window gets destroyed when the app exits and vice versa. Nish


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

        M Offline
        M Offline
        Mr Freeze
        wrote on last edited by
        #3

        Thank you for your reply. I also thought that the window would automatically get destroyed, but in debug mode it tells me that it detected memory leaks (the CFrameWnd and its toolbar)

        C 1 Reply Last reply
        0
        • M Mr Freeze

          Thank you for your reply. I also thought that the window would automatically get destroyed, but in debug mode it tells me that it detected memory leaks (the CFrameWnd and its toolbar)

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          IMO the automatic memory leak detection detects more than is there. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
          C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
          Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

          M 1 Reply Last reply
          0
          • C Christian Graus

            IMO the automatic memory leak detection detects more than is there. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
            C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
            Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

            M Offline
            M Offline
            Mr Freeze
            wrote on last edited by
            #5

            In debug mode I checked if the destructor is called, and it is not called.

            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