Ok so I have 1 user-defined type named fraction
and it represents and ordinary fraction with a numerator and denominator. Here is the code:
class Fr
bool operator<(Fraction& first,Fraction& second)
The problem is that your overload of operator<
only accepts non-const arguments, but the algorithm is trying to compare a constant reference to a Fraction
with the elements in your container.
Since operator<
does not modify the contents of the compared objects, it should take them by const reference:
bool operator<(Fraction const & first,Fraction const & second)