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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. realloc(...) like function in C++

realloc(...) like function in C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++performance
4 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.
  • _ Offline
    _ Offline
    _moved
    wrote on last edited by
    #1

    Hi, I can't find any way to resize class arrays created using "new" is it right to use C memory allocation functions for class arrays and then call constructors/destructors :confused:

    N RaviBeeR 2 Replies Last reply
    0
    • _ _moved

      Hi, I can't find any way to resize class arrays created using "new" is it right to use C memory allocation functions for class arrays and then call constructors/destructors :confused:

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      You definitely wouldn't want to use realloc with an object created with new. You need to leave that old C stuff behind. If you are using MFC CArray or better still STL vector then they will resize themselves as required. Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com

      _ 1 Reply Last reply
      0
      • _ _moved

        Hi, I can't find any way to resize class arrays created using "new" is it right to use C memory allocation functions for class arrays and then call constructors/destructors :confused:

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        If you're using MFC, you can use SetSize() to preallocate a CArray's storage. This is useful when optimizing deserialization of a collection. The size of the collection will grow as you add more elements. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        1 Reply Last reply
        0
        • N Neville Franks

          You definitely wouldn't want to use realloc with an object created with new. You need to leave that old C stuff behind. If you are using MFC CArray or better still STL vector then they will resize themselves as required. Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com

          _ Offline
          _ Offline
          _moved
          wrote on last edited by
          #4

          ok. thanks

          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