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. new and free

new and free

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancequestion
5 Posts 3 Posters 1 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.
  • P Offline
    P Offline
    pix_programmer
    wrote on last edited by
    #1

    Hi! Is it possible to deallocate a memory that was allocated by new using free function? Otherwise what will happen if we deallocate using free function while the memory is allocated using new in C++?

    CPalliniC _ 2 Replies Last reply
    0
    • P pix_programmer

      Hi! Is it possible to deallocate a memory that was allocated by new using free function? Otherwise what will happen if we deallocate using free function while the memory is allocated using new in C++?

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      See here[^].

      Veni, vidi, vici.

      In testa che avete, signor di Ceprano?

      P 1 Reply Last reply
      0
      • CPalliniC CPallini

        See here[^].

        Veni, vidi, vici.

        P Offline
        P Offline
        pix_programmer
        wrote on last edited by
        #3

        Thank you Sir :) .

        CPalliniC 1 Reply Last reply
        0
        • P pix_programmer

          Thank you Sir :) .

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          You are welcome. :)

          Veni, vidi, vici.

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • P pix_programmer

            Hi! Is it possible to deallocate a memory that was allocated by new using free function? Otherwise what will happen if we deallocate using free function while the memory is allocated using new in C++?

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            One thing I would like to add here is that for a UDT, free deallocated memory, whereas delete first calls the destructor and then deallocates memory. Same thing for dynamic array allocation. Hear it from the man himself - Can I mix C-style and C++ style allocation and deallocation?[^]

            «_Superman_»  _I love work. It gives me something to do between weekends.

            _Microsoft MVP (Visual C++)

            Polymorphism in C

            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