I\'m writing a vec3 class for my game physics engine.
I\'ve made an operator overload to allow me to multiply a vector by a scalar (to scale the vector):
<
You need to declare a free operator, outside the class (or inside, as a friend
):
const vec3 operator*( const real n, vec3 v )
{
//no need to re-implement, since you already have v * n defined
return v * n;
}
The reason is that, when declared as a class member, the first operator is implicitly this
, so you basically have defined vec3 * real
.