I just finished building an arraylist class in c++ and was wondering if i did the add method right. I did java programming before but am new with pointers. If anyone has any time could you check out the add method of my code and tell me if you see any flaws. If i did it right then it should double the arrays size every time it fills up and then have my lits point to it.

template <class element>
void ArrayList<element>::add(const element& item)
{
if(length == maxSize)
{
maxSize *= 2;
element *temp = new element[maxSize];

for(int i = 0; i < length; i++)
{
temp[i] = list[i];
}

delete [] list;
list = temp;
temp = NULL;
}

list[length] = item;
length++;
}