Due: 11/12/15 by 11:55PM
Become familiar with the use of Pointers in C++
- Develop familiarity of using functions to process Pointers
Develop the object intArray that creates and manages an array of integers by the use of Pointers. The intArray object will implement a number of useful manipulation of arrays including insert, delete, add, equal, and etc. These functions will limit the use of an array to proper handling. For example these functions will eliminate the possibility of overstepping the boundaries of an array.
Your object should satisfy the following criteria:
- Should be named intArray
- Should contain a default constructor that will set the data pointer to null and size to 0.
- Should contain the alternate constructor intArray(int arraySize, int initValue) that will accept initial size and value for the array. If the initial value is missing, a default value of 0.
- Should contain the alternate constructor intArray(int anArray, int arraySize) that will accept an array and create an object equal to the array.
- The parameter that holds the size of the array should be private.
- Should contain a size() method that will return the size of the array.
- Should contain a set(index, value) method that will set the data[index] = value.
- Should contain a get(index) method that will return data[index].
- Both set and get methods should exit the program if index is outside of the array boundaries.
- Should contain an overloaded assignment operator (=) similar to your previous copy(intArray anIntArray) method that will copy one anIntArray into another.
- Should contain an overloaded equality operator (==) similar to your equal(intArray anIntArray) method that will return true if two arrays are equal in size and content.
- Should contain an overloaded addition and subtraction operator (+, -) similar to your previous add(intArray anIntArray) and subtract(intArray anIntArray) methods that will add or subtract one intArry into/from another.
- The copy, add and subtract methods above should exit the program if size incompatibility is identified.
- Should contain an insert(index, value) method that will insert the value at the index place of an array. The value should be inserted and not replaced.
- Should contain a remove(index) method that will delete the index item of the array. Your method should then return the remove value.
- Both insert and remove should exit the program if the index is invalid, and should expand/shrink the array appropriately.
- Your program should have no memory leaks!
|Due By (Pacific Time)
||11/12/2015 02:00 pm