I have a vec2 class, defined like this
class vec2 {
public:
float x, y;
...
//add a scalar
vec2 operator+(float s) const {
return vec2(this->x + s, this->y + s);
}
};
The operator+ overload works good when doing vec2 v = otherVector * 2.0f;
but doesn't work when doing it backwards, like so vec2 v = 2.0f * otherVector;
.
What's the solution to this?