bool initilize(int size, int val = 0) - This function will allocate space for the pointer (ar) and fill it with val. Notice that this function has a default argument which sets all elements to 0 if nothing is specified. This function should first check to see if the pointer is not NULL. If it is not NULL then the memory associated with the pointer should be deleted so that you avoid a memory leak. This function should then allocate space for the pointer to create the array. You should use size for the number of bytes to allocate. This function also needs to check to make sure the memory was allocated. If it wasn't the function should simply return false. If the memory was allocated then the size variable in the class should be set and ar filled with val. If everything succeeds then the function will return true.
int at(int index) const - This function will first check to make sure that index is not out of bounds and that space has been properly allocated for the array. The function will simply return the value at index or 0 if the index was out of bounds or the pointer was NULL. Please note that returning 0 is not a great thing for this function. We will leave it this way for now and fix it in a future assignment.
void set(int index, int value) - This function will set the array at index with the value provided. The function should also check to make sure that memory has been allocated and that index is not out of bounds. If either of these occur the function should simply return.
int operator [](int index) - This function should simply call the at function because they do the same thing.
Constructors:
CheckedArray() - Default constructor that will set the size of the array to 10 and fill it with 0's.
CheckedArray(int size) - Overloaded constructor which will initialize the array to size and fill it with 0's.
a. You should delegate constructors whenever possible. Your working constructor should also call initialize.
b. You should include a destructor that will check to make sure the pointer is NULL. If it is NULL simply return. Otherwise delete the memory that has been allocated for the pointer.