Original Post
I have two arrays, say I want to move aFooArray to anotherFooArray... I want to make new elements in aFooArray and put the old ones in anotherFooArray, and simply forget the old ones at anotherFooArray. The question is, how to do this fast and without leaking memory? The sure way is to copy every element, but it's slow and, I think, not necessary. The other way is to copy the pointer aFooArray to anotherFooArray, but I'm pretty sure this asking for trouble. I can see a way involving lots of 'new's and 'delete's, but I suppose that's slow as hell... So what's the correct way of doing this? Or should I chance something else? Use std::vector? Or don't use new[]? Other ideas? Also, does this chance for multi-dimensional arrays? Thanks, -Amarth
Foo* aFooArray;
Foo* anotherFooArray;
aFooArray = new Foo[50];
anotherFooArray = new Foo[50];