Data Structures, Algorithms, & Applications in C++
Chapter 5, Exercise 15
The code is given below and in the file
arrayListWithSet.h. Test code is
included in arrayListWithSet.cpp.
template<class T>
class arrayListWithSet : public arrayList<T>
{
public:
// constructor and destructor
arrayListWithSet(int initialCapacity = 10)
: arrayList<T> (initialCapacity) {}
void set(int theIndex, const T& theElement);
};
template<class T>
void arrayListWithSet<T>::set(int theIndex, const T& theElement)
{// Set element i to theElement.
checkIndex(theIndex);
element[theIndex] = theElement;
}