I made a simple Vector2
Template class which I use to store an X
and an Y
value. Now I'm trying to keep implementation of templates in the source files, but I fail to do this with operator overloading
class Vector2
{
public:
Vector2<Type>();
Vector2<Type>(Type x, Type y);
Vector2<Type>(const Vector2<Type> &v);
~Vector2<Type>();
Vector2<Type> operator+ (const Vector2<Type> &other)
{
return Vector2<Type>(x + other.x, y + other.y);
}
private:
Type x, y;
};
Now this compiles and works just fine but this is currently located in the header file. Implementing the constructor and de-constructor of Vector2
works perfectly fine aswell but when I try the following:
.h:
Vector2<Type> operator+ (const Vector2<Type> &other);
.cpp:
template <class Type>
Vector2<Type>::operator+ (const Vector2<Type> &other)
{
return Vector2<Type>(x + other.x, y + other.y);
}
the compiler tells me:
missing type specifier - int assumed. Note C++ does not support default-int
Kind regards, Me