Within int main(), im using Vector<int> objects.
I have a Vector object called X. When doing X = X*0 , i receive "no match for operator*" How can i get the * overload to work with Vector<int> (and <int>) objects?
What should I write?
The problem appeared when i did X = X*1;
In linux, the problem does not exist. However, in windows' Dev C++, the operand 1 has to be typecasted, because 1 is not a float, but an int.
If X is Vector<float> , then i should write X = X*float(1)
template< typename T, typename U >
Vector<T> operator*( const Vector<T>& v, U u );
The idea being that if U is a type incompatible with T, the body of the function won't
compile for some reason. As opposed your solution, which still doesn't compile, but
gives a different compile error.
This allows you to do X = X * 1; without the typecast.