| | | | | |

Implementing Vector<T> Assignment Operator

template <typename T>
Vector<T>& Vector<T>::operator = (const Vector<T>& source) 
// assignment operator
{
   if (this != &source)
   {
      // the NULL case
      if (source.capacity_ == 0)
      {
        if (capacity_ > 0)
          delete [] content_;
        size_ = capacity_ = 0;
        content_ = 0;
        return *this;
      }

      // set capacity 
      if (capacity_ != source.capacity_)
      {
        if (capacity_ > 0)
          delete [] content_;
        capacity_ = source.capacity_;
        content_ = NewArray(capacity_);
      }

      // set size_
      size_ = source.size_;

      // copy content
      for (size_t i = 0; i < size_; ++i)
      {
         content_[i] = source.content_[i];
      }
   }  // end if
   return *this;
}  // end assignment operator =

| | Top of Page | 3. fsu::Vector - 10 of 20