/*           This is the CLASS decleration.      The implementation  is in vector.             */

// vector.h

#ifndef VECTOR_H

#define VECTOR_H

class vector {

// Swap v1 with v2.

friend void swap (vector & v1, vector & v2);

public:

// default constructor: construct a vector of size 0.

vector ();

// Construct a vector of size n and initialize all its elements to x.

vector (int n, double x = 0.0);

// Copy constructor: construct a vector which contains copies of

// all the elements of v.

vector (const vector & v);

// Destructor

~vector();

// Return the number of elements in this vector.

int size() const;

// Return true if this vector has no elements.

int empty() const;

// begin() returns a pointer to the first element of this vector.

// end() returns a pointer just past the end of this vector.

// If this vector is empty, begin() == end().

double * begin() const;

double * end() const;

// lexicographic comparison operators (boolean)

int operator == (const vector & v) const;

int operator < (const vector & v) const;

// Overloaded assignment operator.

// Replace this vector with a copy of vector v.

vector & operator= (const vector & v);

// Return a reference to the nth element from the beginning of the vector.

double & operator[] (int n);

// Return a reference to the first element of the vector.

// Undefined if the vector is empty.

double & front();

// Return a reference to the last element of the vector.

// Undefined if the vector is empty.

double & back();

// Add x to the end of the vector.

void push_back (double x);

// Erase the last element of the vector.

// Undefined if the vector is empty.

void pop_back ();

 

private:

double * array; // the array of numbers

int maxsize; // the number of elements allocated

int currentsize; // the number of "useful" elements

// number of elements to allocate if none is specified

enum {default_capacity = 8};

};

#endif

                                                                          Transcripts

                                                                   Robert's Home Page