//CS2310 Exercise 14 // //Name ___________________ SSN ______________________ // //Chapter 15: p894 - 3 // // SPECIFICATION FILE (expArray.h) // Safe integer array class allows run-time specification // of size, prevents indexes from going out of bounds, // allows aggregate array copying and initialization. // allows expanding the size of array when needed. class ExpArray { public: ExpArray( /* in */ int arrSize ); // Constructor. // PRE: arrSize is assigned // POST: IF arrSize >= 1 && enough memory THEN // Array of size arrSize is created with // all elements == 0 ELSE error message. ~ExpArray( ); // Destructor. // POST: Memory for dynamic array deallocated. int ValueAt ( /* in */ int i ) const; // PRE: i is assigned. // POST: IF 0 <= i < size of this array THEN // FCTVAL == value of array element at index i // ELSE error message. void Store ( /* in */ int val, /* in */ int i ); // PRE: val and i are assigned // POST: IF 0 <= i < size of this array THEN // val is stored in array element i // ELSE error message. void ExpandBy( /* in */ int n); // Precondition: // n > 0 // Postcondition: // Size of array has increased by n elements // && All of the additional n elements equal zero private: int* arr ; int size ; };