Search:

Type: Posts; User: helloworld922

Search: Search took 0.12 seconds.

  1. Re: Have a C++ project due soon and am not sure if I'm using pointers right.

    Which chunk of memory do you want to keep, the one pointed to by array, or the one pointed to by newArray (note: this is before they both point to the same array)?
  2. Re: Have a C++ project due soon and am not sure if I'm using pointers right.

    For the creation of the array, yes. You still need to manage memory cleanup or you'll be left with memory leaks.

    memory management - What and where are the stack and heap - Stack Overflow
  3. Re: Have a C++ project due soon and am not sure if I'm using pointers right.

    Yes, in push_back:

    int newArray[getSize() * 2];

    If this was legal (it isn't because C++ doesn't allow dynamic sized arrays on the stack), the actual array would go out of scope and be reclaimed...
  4. Re: Have a C++ project due soon and am not sure if I'm using pointers right.

    C++ does not allow for dynamically sized arrays on the stack, you must allocate the array on the heap (a.k.a. using "new"), then you will need to delete it when you're done. Even assuming that you...
Results 1 to 4 of 4