If I understand the question correctly, you could use the function in the reference as is.
oldArray = GrowArray(oldArray, oldCount, newCount);
It could be modified to use a local temporary and then std::swap
, but this would depend a lot on the context in which it is used.
1
solved Reallocating an array that is an instance member [closed]