// UBVector.h // we are explicit in writing down some argument names so that it is clear what // the functions are supposed to do #ifndef _UBVECTOR_H #define _UBVECTOR_H class UBVector { public: // constructors and assignment operator explicit UBVector(size_t n=0); // construct a UBVector with n strings UBVector(const UBVector&); // copy constructor UBVector& operator=(const UBVector& another_ubvec); // destructor ~UBVector(); // accessors std::string& operator[](size_t index); const std::string& operator[](size_t index) const; std::string& front(); const std::string& front() const; std::string& back(); const std::string& back() const; // capacity size_t size() const { return num_items; } size_t capacity() const { return current_capacity; } bool empty() { return num_items == 0; } void reserve(size_t n); // modifiers void push_back(const std::string& value); void pop_back(); void insert(size_t position, const std::string& value); void erase(size_t position); void swap(UBVector& another_ubvec); // swap content with one another private: size_t num_items; size_t current_capacity; static const size_t INITIAL_CAPACITY; std::string *item_ptr; }; #endif