It's conventional to use just operator<.
The reason is, if you make an object that goes into a sorted containter, it reduces the number operations that you need to implement.
Back to your code. Your class should not implement operator>, it should implement just operator<.
You can do this either by implementing operator< within the class as in:
1 2 3
|
struct Results
{
bool operator<(const Results &) const;
|
or an external function that takes the two values:
|
bool operator<(const Results &l, const Results &r);
|
Please note the use of const & as parameters.
If your
if clauses end with a
return, you can avoid the
else as it's implied.
You can't test floating point number for equality in that way. They're equal if the difference is less than the epsilon for the type.
As as mentioned above, comparison shouldn't change the state of the object being compared. So you shouldn't be sorting in your comparison. In the prototypes above, the objects are const, so we promise not to modify them.