3. Refresh your C++#
We assume you have a basic knowledge of C++, and repeat only shortly some features of the C++ programming language. Here is a list of C++ books.
template <typename T>
class Vector
{
  size_t size;
  T * data;
public:
  Vector (size_t _size) 
    : size(_size), data(new T[_size]) { ; }
  Vector (const Vector & v)  // copy ctor
    : Vector(v.Size())
  {
    *this = v;
  }
  Vector (Vector && v)    // move ctor
    : size(0), data(nullptr)
  {
    std::swap(size, v.size);
    std::swap(data, v.data);
  }
  ~Vector () { delete [] data_; }
  Vector & operator= (const Vector & v2)
  {
    for (size_t i = 0; i < size; i++)
      data_[i] = v2(i);
    return *this;
  }
  Vector & operator= (Vector && v2)
  {
    std::swap(size, v.size);
    std::swap(data, v.data);
    return *this;
  }
  size_t Size() const { return size; }
  
  T & operator() (size_t i) { return data[i]; }
  const T & operator() (size_t i) const { return data[i]; }
};
- We define a class template - Vector. The type of the vector elements is given by the template argument- T. For example, one can define a vector with 10 double precision entries as- Vector<double> v(10).
- A Vector object can be created by one of its constructors, and is destroyed by the destructor. 
- We use the move-semantics introduced with C++11. If a Vector is initialized from a return-value Vector (which will be destroyed anyway), the move-constructor can steal resources from the temporary vector (see rule of five). 
- All data members are private, what means invisible form outside. The interaction with an Vector object happens only via its methods ( - Size, assignment- operator=and call- operator()). We have chosen the call operator () instead of bracket operator [] for consistency with the- Matrixclass.
The function operator+ for adding two vectors of the same type T is as follows:
template <typename T>
Vector<T> operator+ (const Vector<T> & a, const Vector<T> & b)
{
  Vector<T> sum(a.Size());
  for (size_t i = 0; i < a.Size(); i++)
    sum(i) = a(i)+b(i);
  return sum;
}  
Coding styles: it is a good recommendation to follow a coherent programming style within one project, this includes
- naming convention for classes, functions, and variables 
- indentation, spaces before/after operators and brackets 
We try to follow the Google C++ Style Guide.
Some recommendations from experts https://isocpp.org/wiki/faq/coding-standards#coding-std-wars
