SO,
I am running into an error which I cannot figure out (unless my understanding is just incorrect).
I have the following code:
int doubleSize=size*2;
int *newArr = new int[doubleSize];
for(int i=0; i<size; i ++) {
newArr[i]=jon[i];
}
size*=2;
display(newArr);
jon=newArr;
display(jon);
delete[] newArr;
display(jon);
After the first and second calls I get exactly what I want/expect. On the third display call the 0 and 1 indices are memory addresses, the rest of the values in the indices match the previous 2 calls. What could be causing this?
I also have another follow up question, with code as I have it, will not deleting jon[] cause the 'old' jon[] to stay in memory?
Thanks!