Yes, I realized it later. I don't know what I was thinking. But I don't care about memory allocation failures in this stage :). But yes, your code is obviously the way to go.
Code:
void ResizeOne()
{
T* temp = new T[m_intSize+1];
for(int i = 0; i < m_intSize; ++i)
temp[ i ] = internalData[ i ];
delete[] internalData;
internalData = temp;
m_intSize++;
} By the way.
You checked for null pointer failure but it is tedious to code
throw bad_alloc(); after every
new. So I would never check for NULL these days.
But if one has an old compiler then one should throw an exception if it runs out of memory. Do this by
forcing new to
throw alloc_error();. Obviously you will have to implement such a thing as:
set_new_handler(theNewHandler).
Although this method doesn't come with guarantees. But I don't know a better way wich pays of at my work (time).