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. CArray on the heap

CArray on the heap

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
4 Posts 4 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.
  • S Offline
    S Offline
    sschilachi
    wrote on last edited by
    #1

    Is there any way to create a CArray object on the heap rather than on the stack? Thanks

    D N 2 Replies Last reply
    0
    • S sschilachi

      Is there any way to create a CArray object on the heap rather than on the stack? Thanks

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Yes, but why would you want to? As you add items to the array, memory is allocated from the heap to hold the individual items. The array object itself consumes very little memory.


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      R 1 Reply Last reply
      0
      • D David Crow

        Yes, but why would you want to? As you add items to the array, memory is allocated from the heap to hold the individual items. The array object itself consumes very little memory.


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

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

        My guess is he wants it to exist outside the scope of the creating block. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        1 Reply Last reply
        0
        • S sschilachi

          Is there any way to create a CArray object on the heap rather than on the stack? Thanks

          N Offline
          N Offline
          Navin
          wrote on last edited by
          #4

          Simple:CArray<int> *theArray = new CArray<int>; // Examples of populating the array theArray->Add(1); theArray->Add(42); theArray->SetAt(0, 1337);
          Or am I missing something? :confused: Remember, even if you win the rat race, you're still a rat.

          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