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. Destructor Question...

Destructor Question...

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

    How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd

    J R 2 Replies Last reply
    0
    • C CDuddley

      How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      If you create the object with new the destructor is called as part of the operations performed by delete. If the object is created on the stack (no new), the destructor is called when the object goes out of scope (e.g. if it is a local variable inside a function, the destructor is called when the function exits). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      1 Reply Last reply
      0
      • C CDuddley

        How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        An object is destructed when explicitly deleted or when it goes out of scope, if created on the stack. An object is also destructed when its containing object (if any) is destructed. This applies to implicitly constructed members of the containing class. Dynamically created members need to be explicitly deleted. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

        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