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. about C++

about C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++oop
5 Posts 5 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
    Chau Ngoc Vo
    wrote on last edited by
    #1

    Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,

    C J P P 4 Replies Last reply
    0
    • C Chau Ngoc Vo

      Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,

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

      Chau Ngoc Vo wrote: about C++ Um... a question about C++ in the C++ forum, who would have thought ? You'll get more readers if you actually say something in your headers. Chau Ngoc Vo wrote: I said that no body do at that. But he said it is used a lot of in MFC. Did either of you think to actually type this into a compiler and see what it spits back ? Your friend is right. If it's used in MFC or not, I don't know. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • C Chau Ngoc Vo

        Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #3

        It's often used in MFC and ATL where instances are stored in a OS objects that have no knowledge of C++. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        1 Reply Last reply
        0
        • C Chau Ngoc Vo

          Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,

          P Offline
          P Offline
          Phil Hamer
          wrote on last edited by
          #4

          It's used in CFrameWnd in PostNcDestroy. CFrameWnds should always be created with new, so it can call "delete this" as the last thing it does before the window is gone.

          1 Reply Last reply
          0
          • C Chau Ngoc Vo

            Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,

            P Offline
            P Offline
            Prakash Nadar
            wrote on last edited by
            #5

            Another example of delete self is in modeless dialog box. modeless dialog boxes delete themself The World is getting smaller and so are the people.

            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