An Array Template Class

Create a template class for creating and manipulating one dimensional arrays.

You will need to create:

  1. a default constructor
  2. a constructor with a parameter for capacity
  3. a copy constructor.

We will need the member functions:

  addElement()
  isempty()
  isfull()
  getCapacity() //actual size of the array
  getUsed() //number of elements currently in the array
  removeElement().

Let the remove function overwrite the element to be removed with the last element in the array, so that there are no ‘holes’ in the used portion of the array. An empty array and an array with one element are special cases for the remove member function.

You do not have to make the array resizable.

You can declare the array data field as:

   T  *a;

You will need to overload the operators [], which accesses and changes elements in the array, and = which assigns “other” array to “this” array.

Since the array is not held within the object, you will also need a destructor.

Create an application that demonstrates the functions you wrote.

courses/cs203-200803/assignments/assignment_8_link.txt · Last modified: 2009/04/14 15:22 by jones
VCCS Top Events Extended Site Search Login Vassar Science Web Vassar Home Driven by DokuWiki Valid XHTML 1.0