There is nothing inherently wrong with what you do. However, if it is a member function of a class, and list is a member variable, keep in mind that the code you have is not safe.
In other words, if for some reason the new[] call failed, your list array has been destroyed and you cannot restore the data.
Better to do it:
void NewList(int size) { ListObject* temp = new ListObject[size]; delete[] list; list = temp; }
If calling new[] throws an exception, you have not destroyed the original data.
However, all this will take care if you used std::vector , as others suggested.
source share