So in C++, I read that C realloc(&dest, &source, nbytes)
is bad because it doesn't work with new and delete.
So how to reallocate data correctly in C++? Assume I have:
int* a = new int[100];
But I wish to resize it to int[200]. The simplest way I think of is:
int* old = a;
int* newPos = new int[200];
memcpy(newPos, a, sizeof(int)*100);
a = newPos;
delete[] old;
Is there a simpler way? Thank you