// File: array2.h // // An array class for testing sorting algorithms (version 2) #ifndef _array2_h #define _array2_h #include #include #include #include #define DATA float #define DSIZE 50 class Array { public: Array() ; // default constructor Array(int n, long seed=0) ; // constructor Array(const Array&) ; // copy constructor Array& operator=(const Array&) ; // assignment ~Array() ; // destructor void print() const ; // dump array to screen bool check() const ; // is array sorted? DATA *arr ; // dynamically allocated array // Inline functions // inline int length() const { return size; } inline DATA& operator[](int) ; protected: // semi-private long seed ; int size ; } ; // Inline functions not defined in the declaration // inline DATA& Array::operator[](int i) { // debugging mode // assert(i >= 0) ; assert(i < size) ; return arr[i] ; } #endif