/**************************************************************** example 1 - safearray.h developing our "safe" array ****************************************************************/ #include <iostream> using namespace std; #include <process.h> //for the exit() function //constant that sets the size of all arrays in the class const int maxsize = 100; //class definition class safearray { private: int array[maxsize]; public: void put(const int& pos, const int& value) { if ((pos < 0) || (pos >= maxsize)) { cerr << endl << "Index out of bounds" << endl; exit(1); } array[pos]=value; } int get(const int& pos) const { if ((pos < 0) || (pos >= maxsize)) { cerr << "\nIndex out of bounds"; exit(2); } return array[pos]; } };