So I have these two overloaded operators for my Vector class, dot and cross product, I assume you cannot do this, and I should have a cross function instead.
inline T operator *(const Vector3<T> &v)
{
return value[0]*v[0]+value[1]*v[1]+value[2]*v[2];
}
inline Vector3<T> operator *(const Vector3<T> &v)
{
Vector3<T> result;
result[0] = value[1]*v[2] - value[2]*v[1];
result[1] = value[2]*v[0] - value[0]*v[2];
result[2] = value[0]*v[1] - value[1]*v[0];
return result;
}
In the off chance there is a way to do this that would be great, is it at all possible?
You can’t overload on return type.
You have a few choices:
dot(v1, v2);v1 ^ v2) as the dot or cross operator (note that the precedence may not be what you want);v1 <dot> v2, using the<and>operators and a globaldotobject).