I have an assignment at my university. My task is to complete two header files with the implementation of the given classes. It is important to implement in those header files, because it will be tested by unit tests and only the header files will be tested.
Let's say I have this .h file:
#pragma once
template<class T>
class RareVector;
template<class T>
class Vector
{
public:
Vector(){}
Vector(int dim);
Vector(T *t, int dim);
Vector(const Vector&);
~ Vector();
Vector operator+(const Vector&);
Vector operator-(const Vector&);
double operator*(const Vector&);
double operator~();
double operator%(const Vector&);
T operator[](int) const;
operator RareVector<T>();
private:
T* m_t;
int m_dim;
};
My question is: the only place to implement these classes is at the declaration, or I can do something like this somewhere below:
template <class T>
Vector<T>::Vector(){
// code goes here
}