# C++ Notes: Classes: Example: floatVector.h - Version 1

The header file for the `floatVector` class. See Example: floatVector - Version 1 for links to the test and implementation files.

      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
    // fv1/loatVector.h - Illustrates typical vector features
    //  Fred Swartz - 2004-12-01

    #ifndef floatVector_H
    #define floatVector_H

    class floatVector {
      public:
        floatVector();        // default constructor
        ~floatVector();       // destructor

        float& at(int position) const; // ref to element at position
        float& back() const;           // reference to last elem
        int    capacity() const;       // max size before reallocation.
        void   clear();                // delete all items
        void   push_back(float item);  // add item to end
        void   reserve(int cap);       // insure capacity at least cap.
        int    size() const;           // number of elements in vector

      private:
        int    _capacity;     // current maximum size (number of floats).
        int    _size;         // current "size"
        float* _data;         // pointer to array of floats
    };
    #endif