Thanks. That makes a lot of sense and not sure how I missed some of it.
I've been playing with a few things that work, but not sure which is the best. This is what I've had that works, but relies on temporary storage:
Code:
template<typename T>
void ArrayStack<T>::doubleArraySize() {
capacity *= 2;
T tempArray[tos+1];
for (int i=0; i<=tos; i++) {
tempArray[i] = array[i];
}
array = new T[capacity];
for (int i=0; i<=tos; i++) {
array[i] = tempArray[i];
}
}
-This works, but i'm not sure how I should release the other memory when i reassign the pointer. Also, i'm not sure if this is the ideal way to do what I'm wanting to do.