The logic of the operator aside, you seem to be missing a set of parentheses in the if
. This would by syntactically correct:
if ( (x <= v.x) && (y <= v.y) && (z <= v.z) )
But what you really should do is simplify the whole thing and avoid the unnecessary if
:
bool operator<= (Vector3 v) {
return (x <= v.x) && (y <= v.y) && (z <= v.z);
}
Finally, a comparison member function should be const
, because it does not make sense to modify something while comparing it. Also, you may want to pass the argument by reference, although that depends on the size of Vector
and on the cost to copy it.
bool operator<= (const Vector3& v) const
{
return (x <= v.x) && (y <= v.y) && (z <= v.z);
}