//This is header file intarray.h //Class for a well behaved integer array. //Arrays are declared as follows //IntArray my_array(size_of_array); //Note round brackets. You can use a variable for the size //of the array. //Regular a[i] notation works for indexed variables. //If an out of range index is used, then //an error message is sent to the screen and the program ends. #ifndef INTARRAY_H #define INTARRAY_H #include typedef int* IntPtr; class IntArray { public: IntArray(int the_size); //Creates an array of the_size elements. //Initializes all elements to 0. IntArray(); //Creates an array of 10 elements. //Initializes all elements to 0. IntArray(const IntArray& other_array); //Initializes all elements to match other_array. ~IntArray(); //Returns all dynamic memory to be recycled. int& operator[](int index); //Overloaded to behave like regular array []. //But gives error message for index out of range. void operator =(const IntArray& right_side); //If left side of assignment operator is too small //to hold all the elements in right_side, then the left //side is made larger. int get_size() const; void resize(int new_size); //Changes the size of the array. If the size increases or is //the same, then the old elements stay. If the size decreases, //as many of the old elements as will fit are preserved. friend ostream& operator <<(ostream& outs, const IntArray& ar); //Outputs ar[0] ar[1] through ar[get_size() -1] //All on one line. Separated by one space after each. private: IntPtr a;//Pointer to a dynamic array. int size;//Size of the dynamic array. }; #endif //INTARRAY_H