I'm writing a List Class for use in a school project (it's not due in a week or two, not monday) and when I use it to insert an item, the program crashes. I have an idea of what is wrong, but I'm not sure what to do; I just can't see how to fix it.

I believe the problem is with the constructor and/or the insert function. The problem is that it is trying to insert an item at an invalid point in the list. I will post the few functions, if you need to see the whole project, I will post it.

Those are in the header file; this is how I use it in the driver.cpp file.Code:template <class T> bool List<T>::isEmpty() { return numItems == -1; } template <class T> bool List<T>::isFull() { return numItems == MAXSIZE; } template <class T> bool List<T>::isValidPos(int n) { if ((n >= 0) && (n < numItems)) return true; //if ((n > numItems) || (n < 1)) // return false; return false; } template <class T> List<T>::List(int n):MAXSIZE(n) { data = new T[MAXSIZE]; numItems = 0; curpos = 0; } template <class T> bool List<T>::insert(const T &r) { if (isFull()) return false; if (isValidPos()) { for (int i=numItems; i>=curpos; i--) data[i+1] = data[i]; data[curpos] = r; numItems++; return true; } return false; }

Thanks for help, but please don't post code.Code:int main() { List<int> a(10); a.insert(1); a.insert(2); int tmp; a.getData(tmp); cout << tmp << endl; a.next(); a.getData(tmp); cout << tmp << endl; return 0; }