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)?
Type: Posts; User: helloworld922
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)?
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
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...
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...