Hey guys, I'm stuck on this assignment and was wondering if you could give me any pointers? The directions are:
Design and implement the class myArray that solves the array index out of bound problem, and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements:
myArray<int> list(5); // Line 1
myArray<int> myList(2,13); //Line 2
myArray<int> yourList(-5,9); // Line 3
The statement in Line 1 declares list to be an array of 5 components, the component type is int, and the componentst are : list[0], list[1]…list[4]; the statement in Line 2 declares mylist to be an array of 11 components, the component type is int, and the components are: mylist[2],…mylist[12].
I really have no idea how to approach this problem. This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#ifndef H_myArray
#define H_myArray
#include <iostream>
using namespace std;
template <class myArray>
class myArray
{
public:
private:
return 0;
};
#endif
|