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. The Lounge
  3. delete and delete[]

delete and delete[]

Scheduled Pinned Locked Moved The Lounge
questionc++data-structuresannouncement
21 Posts 13 Posters 2 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 Chris Maunder

    delete? [digs into memory] Oooooh - that thing you used to have to do way back in the olden days when memory management was a problem. Right. ;P OK - I admit. I miss delete. I really do cheers, Chris Maunder

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

    ROTFL - very good. Actually, I'm torn between liking how much easier C# is, and the feeling that I'm becoming less skilled because I don't have to work as hard as I used to, as a matter of course. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

    H 1 Reply Last reply
    0
    • C Christian Graus

      No, this isn't a programming question. I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? If so, does anyone have an online reference to the fact ? Note: I NEVER use delete without the [] to delete an array, but I thought that proper form didn't make a difference, is all. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #4

      Christian Graus wrote: I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? As far as I remember, that was true only for primitive types (without destructors).

      C 1 Reply Last reply
      0
      • C Christian Graus

        No, this isn't a programming question. I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? If so, does anyone have an online reference to the fact ? Note: I NEVER use delete without the [] to delete an array, but I thought that proper form didn't make a difference, is all. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        G Offline
        G Offline
        Graham Bradshaw
        wrote on last edited by
        #5

        The problem is that if you "mix and match", the destructor is only called for the first object in the array. ie LPBYTE pData = new CObject[10]; delete pData; // only the destructor for first allocated CObject is called but delete [] pData; // all 10 destructors are called, one for each allocated CObject (Graham clicks Submit, dashes off to put on flame-proof clothing for encouraging programming questions in the Lounge, and hides under the desk, quivering nervously)

        1 Reply Last reply
        0
        • C Chris Maunder

          delete? [digs into memory] Oooooh - that thing you used to have to do way back in the olden days when memory management was a problem. Right. ;P OK - I admit. I miss delete. I really do cheers, Chris Maunder

          N Offline
          N Offline
          Nemanja Trifunovic
          wrote on last edited by
          #6

          Chris Maunder wrote: the olden days when memory management was a problem. You mean before STL and smart pointers, right? ;)

          1 Reply Last reply
          0
          • N Nemanja Trifunovic

            Christian Graus wrote: I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? As far as I remember, that was true only for primitive types (without destructors).

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

            The type in question is a char *, so it would stand. Do you have any references ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

            N 1 Reply Last reply
            0
            • C Chris Maunder

              delete? [digs into memory] Oooooh - that thing you used to have to do way back in the olden days when memory management was a problem. Right. ;P OK - I admit. I miss delete. I really do cheers, Chris Maunder

              T Offline
              T Offline
              Tom Archer
              wrote on last edited by
              #8

              You don't use it in VB or VBScript so you can go back to sleep ;P Cheers, Tom Archer "Use what talents you possess. The woods would be very silent if no birds sang there except those that sang best." - William Blake * Inside C# -Second Edition * Visual C++.NET Bible * Extending MFC Applications with the .NET Framework

              1 Reply Last reply
              0
              • C Christian Graus

                The type in question is a char *, so it would stand. Do you have any references ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                N Offline
                N Offline
                Nemanja Trifunovic
                wrote on last edited by
                #9

                Christian Graus wrote: Do you have any references ? Nope. Don't quote me on this, I just *think* I remember this being true.

                1 Reply Last reply
                0
                • C Christian Graus

                  ROTFL - very good. Actually, I'm torn between liking how much easier C# is, and the feeling that I'm becoming less skilled because I don't have to work as hard as I used to, as a matter of course. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #10

                  I kind of get that feeling too from time to time, which is why I at least try to write a bit of unmanaged code from time to time, like my shell extensions for .NET assemblies here on CP - yeah, I know, it's still geared toward .NET. :sigh: What's weird is saying "unmanaged code". It used to just be "code". But then again, "organic produce" just used to be "produce", but now you have to pay extra for getting produce grown the way it was intended.

                  Microsoft MVP, Visual C# My Articles

                  C 1 Reply Last reply
                  0
                  • H Heath Stewart

                    I kind of get that feeling too from time to time, which is why I at least try to write a bit of unmanaged code from time to time, like my shell extensions for .NET assemblies here on CP - yeah, I know, it's still geared toward .NET. :sigh: What's weird is saying "unmanaged code". It used to just be "code". But then again, "organic produce" just used to be "produce", but now you have to pay extra for getting produce grown the way it was intended.

                    Microsoft MVP, Visual C# My Articles

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

                    I REFUSE to say unmanaged code. It's not unmanaged, it's SELF managed. Microsoft can get stuffed if they want to imply those things are the same. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      No, this isn't a programming question. I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? If so, does anyone have an online reference to the fact ? Note: I NEVER use delete without the [] to delete an array, but I thought that proper form didn't make a difference, is all. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                      G Offline
                      G Offline
                      George
                      wrote on last edited by
                      #12

                      There is an extensive explanation on the subject in September 1996 "C++ Q & A" by Paul DiLascia: http://www.microsoft.com/msj/archive/S202C.aspx[^] You have to scroll down a little bit to the chapter starting "I've been teaching myself C++"

                      /* I C++, therefore I am... */

                      C 1 Reply Last reply
                      0
                      • C Christian Graus

                        No, this isn't a programming question. I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? If so, does anyone have an online reference to the fact ? Note: I NEVER use delete without the [] to delete an array, but I thought that proper form didn't make a difference, is all. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                        A Offline
                        A Offline
                        Anders Molin
                        wrote on last edited by
                        #13

                        Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application[^]

                        My Photos[^]

                        J 1 Reply Last reply
                        0
                        • G George

                          There is an extensive explanation on the subject in September 1996 "C++ Q & A" by Paul DiLascia: http://www.microsoft.com/msj/archive/S202C.aspx[^] You have to scroll down a little bit to the chapter starting "I've been teaching myself C++"

                          /* I C++, therefore I am... */

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

                          Thanks - that's just what I was looking for. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                          1 Reply Last reply
                          0
                          • A Anders Molin

                            Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application[^]

                            My Photos[^]

                            J Offline
                            J Offline
                            Jack Puppy
                            wrote on last edited by
                            #15

                            Anders Molin wrote: Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. I think this is part of a disease I call... Paradoxal Prefaceitious! Ever notice how people will preface their statements with contradictions in order that society, for whatever reason, will be more accepting of the later half of their statement? Here are the classic lines I love hearing: "No offense, but..." - followed by a completely offensive remark. "I don't mean to sound racist, but..." - followed by a remark that would make the KKK proud. The classic radio talk show caller statement: "I know you've got alot of callers waiting, so I'll be brief" - followed by 15 minutes of non-stop yapping that puts Foghorn Leghorn to shame. How a question about delete vs delete[] isn't considered a programming question is beyond me. The art of paradoxal prefaceitious has amazing powers, doesn't it?

                            "You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb

                            M P A 3 Replies Last reply
                            0
                            • J Jack Puppy

                              Anders Molin wrote: Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. I think this is part of a disease I call... Paradoxal Prefaceitious! Ever notice how people will preface their statements with contradictions in order that society, for whatever reason, will be more accepting of the later half of their statement? Here are the classic lines I love hearing: "No offense, but..." - followed by a completely offensive remark. "I don't mean to sound racist, but..." - followed by a remark that would make the KKK proud. The classic radio talk show caller statement: "I know you've got alot of callers waiting, so I'll be brief" - followed by 15 minutes of non-stop yapping that puts Foghorn Leghorn to shame. How a question about delete vs delete[] isn't considered a programming question is beyond me. The art of paradoxal prefaceitious has amazing powers, doesn't it?

                              "You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb

                              M Offline
                              M Offline
                              Maxwell Chen
                              wrote on last edited by
                              #16

                              Jack Rabbit wrote: Paradoxal Prefaceitious! Jack, you are a man of insight! ;) Maxwell Chen

                              1 Reply Last reply
                              0
                              • J Jack Puppy

                                Anders Molin wrote: Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. I think this is part of a disease I call... Paradoxal Prefaceitious! Ever notice how people will preface their statements with contradictions in order that society, for whatever reason, will be more accepting of the later half of their statement? Here are the classic lines I love hearing: "No offense, but..." - followed by a completely offensive remark. "I don't mean to sound racist, but..." - followed by a remark that would make the KKK proud. The classic radio talk show caller statement: "I know you've got alot of callers waiting, so I'll be brief" - followed by 15 minutes of non-stop yapping that puts Foghorn Leghorn to shame. How a question about delete vs delete[] isn't considered a programming question is beyond me. The art of paradoxal prefaceitious has amazing powers, doesn't it?

                                "You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb

                                P Offline
                                P Offline
                                Paul Lyons
                                wrote on last edited by
                                #17

                                :laugh::laugh::laugh: Thanks for the laugh! Shouldn't it really be paradoxal prefacitis?

                                itis

                                -itis \-i"tis\, [Gr. ?, orig, fem. adjective suffix.] A suffix used in medical terms
                                to denote an inflammatory disease of; as, arthritis; bronchitis, phrenitis.

                                Funny stuff either way!

                                Paul Lyons, CCPL
                                Certified Code Project Lurker

                                M I 2 Replies Last reply
                                0
                                • P Paul Lyons

                                  :laugh::laugh::laugh: Thanks for the laugh! Shouldn't it really be paradoxal prefacitis?

                                  itis

                                  -itis \-i"tis\, [Gr. ?, orig, fem. adjective suffix.] A suffix used in medical terms
                                  to denote an inflammatory disease of; as, arthritis; bronchitis, phrenitis.

                                  Funny stuff either way!

                                  Paul Lyons, CCPL
                                  Certified Code Project Lurker

                                  M Offline
                                  M Offline
                                  Maxwell Chen
                                  wrote on last edited by
                                  #18

                                  Paul Lyons wrote: Shouldn't it really be paradoxal prefacitis? Nice one! :-D I am not a native English speaker. The previous spelling, prefaceitious, took me some time to look it up in dictionaries, but I don't find it. :doh: Maxwell Chen

                                  1 Reply Last reply
                                  0
                                  • P Paul Lyons

                                    :laugh::laugh::laugh: Thanks for the laugh! Shouldn't it really be paradoxal prefacitis?

                                    itis

                                    -itis \-i"tis\, [Gr. ?, orig, fem. adjective suffix.] A suffix used in medical terms
                                    to denote an inflammatory disease of; as, arthritis; bronchitis, phrenitis.

                                    Funny stuff either way!

                                    Paul Lyons, CCPL
                                    Certified Code Project Lurker

                                    I Offline
                                    I Offline
                                    Iain Clarke Warrior Programmer
                                    wrote on last edited by
                                    #19

                                    And there was me thinking it was a clever combination of prefacitis and facetious[^]! That's just me overcomplicating again... Iain.

                                    1 Reply Last reply
                                    0
                                    • J Jack Puppy

                                      Anders Molin wrote: Christian Graus wrote: No, this isn't a programming question. Err, why not? It fits perfectly in the C++ forum. I think this is part of a disease I call... Paradoxal Prefaceitious! Ever notice how people will preface their statements with contradictions in order that society, for whatever reason, will be more accepting of the later half of their statement? Here are the classic lines I love hearing: "No offense, but..." - followed by a completely offensive remark. "I don't mean to sound racist, but..." - followed by a remark that would make the KKK proud. The classic radio talk show caller statement: "I know you've got alot of callers waiting, so I'll be brief" - followed by 15 minutes of non-stop yapping that puts Foghorn Leghorn to shame. How a question about delete vs delete[] isn't considered a programming question is beyond me. The art of paradoxal prefaceitious has amazing powers, doesn't it?

                                      "You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb

                                      A Offline
                                      A Offline
                                      Anders Molin
                                      wrote on last edited by
                                      #20

                                      Yeah, and one more thing... When this is posted by someone like Christian Graus, no one minds, but if some newbie posted it, everyone would jump on him and tell him not to post that kinda crap in the lounge... Interesting eh? - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application[^]

                                      My Photos[^]

                                      1 Reply Last reply
                                      0
                                      • C Christian Graus

                                        No, this isn't a programming question. I seem to recall that on some version of VC++, delete and delete[] do the same thing, am I right in thinking that ? If so, does anyone have an online reference to the fact ? Note: I NEVER use delete without the [] to delete an array, but I thought that proper form didn't make a difference, is all. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                                        M Offline
                                        M Offline
                                        Mike Dimmick
                                        wrote on last edited by
                                        #21

                                        Raymond Chen: Mismatching scalar and vector new and delete[^] Stability. What an interesting concept. -- Chris Maunder

                                        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