// SimpleList.cpp - wdg - 2008 // implementation code for a list of doubles // uses partially filled array #include using namespace std; template SimpleList::SimpleList(int cap) : count(0), capacity(cap), A(new T[cap]) { } template void SimpleList::add(T item) { if( count == capacity ) throw invalid_argument("No room in list"); A[count]=item; count++; } template T SimpleList::getItem(int position) const { if( position<0 || position>=count) throw invalid_argument("Invalid position"); return A[position]; } template SimpleList & SimpleList::operator=(const SimpleList & rhs) { if ( this!= &rhs ) { // uses addressof operator so that compare pointers capacity = rhs.capacity; count = rhs.count; delete [] A; A = new T[capacity]; for(int i=0; i