//----------------------------------------------------------------------
//  SPECIFICATION FILE (vector.h)
//  This module exports an integer vector class that allows:
//    1. Run-time specification of vector size
//    2. Trapping of invalid subscripts
//    3. Aggregate vector assignment
//    4. Aggregate vector initialization (for parameter passage by
//       value, function value return, initialization in a declaration)
//----------------------------------------------------------------------

class IntVec {
public:
    void operator=( /* in */ IntVec vec2 );
        // POST: IF size of this vector == size of vec2 THEN
        //          Each element of this vector == corresponding element
        //                                         of vec2
        //       ELSE
        //          Pgm has halted with error message

    int& operator[]( /* in */ int i ) const;
        // POST: IF 0 <= i < (declared size of vector) THEN
        //          FCTVAL == address of element i of vector
        //       ELSE
        //          Pgm has halted with error message
        // NOTE: Because return type is "int&", not "int*", the result
        //       is automatically dereferenced in the calling code.
        //       Caller uses   someVec[6] = 943;
        //              not    *(someVec[6]) = 943;

    IntVec( /* in */ int numElements );
        // Constructor
        // POST: IF numElements >= 1 THEN
        //          Uninitialized vector of size numElements is created
        //       ELSE
        //          Pgm has halted with error message

    IntVec( const IntVec& anotherVec );
        // Constructor (a "copy-constructor")
        // POST: New vector created with size and contents same
        //       as anotherVec
        // NOTE: This constructor is implicitly invoked whenever an
        //       IntVec is passed by value, is returned as a
        //       function value, or is initialized by another
        //       IntVec in a declaration.

    ~IntVec();
        // Destructor
        // POST: Vector no longer exists
private:
    int* vec;
    int  size;
};

