title: C++ class operator overloads don't work with std::sort
body: <p>So I have been been trying to build a median generator that takes in fractions and generates the median however it seems like currently I am unable to sort a vector of my self defined RationalNumber class. I have overloaded a number of the operators ( * + / ==  etc etc) however they don't seem to work when called inline elsewhere.</p>
  
  <pre><code>RationalNumber RationalNumber::operator*(const RationalNumber&amp; r)
  {
      RationalNumber result(numerator * r.numerator, denominator * r.denominator);
      result.reduceFraction();
      return result;
  }   
  
  RationalNumber RationalNumber::operator*(int x)
  {
      RationalNumber result(numerator * x, denominator);
      result.reduceFraction();
      return result;
  }
  
  RationalNumber RationalNumber::operator/(const RationalNumber&amp; r)
  {
      RationalNumber result(numerator * r.denominator, denominator * r.numerator);
      result.reduceFraction();
      return result;
  }
  
  RationalNumber RationalNumber::operator/(int x)
  {
      RationalNumber result(numerator, denominator * x);
      result.reduceFraction();
      return result;
  }
  bool RationalNumber::operator&lt;(const RationalNumber&amp; r)
  {
      if(this-&gt;floatingPoint &lt; r.floatingPoint)
      {
          return true;
      }
  
      return false;
  }
  
  bool RationalNumber::operator&lt;(int x)
  {
      if(floatingPoint &lt; (double) x)
      {
          return true;
      }
  
      return false;
  }
  
  bool RationalNumber::operator&gt;(const RationalNumber&amp; r)
  {
      if(floatingPoint &gt; r.floatingPoint)
      {
          return true;
      }
      return false;
  }
  
  bool RationalNumber::operator&gt;(int x)
  {
      if(floatingPoint &gt; (double) x)
      {
          return true;
      }
      return false;
  }
  
  RationalNumber RationalNumber::operator+(const RationalNumber&amp; r)
  {
      RationalNumber result((numerator * r.denominator)+(r.numerator*denominator),denominator * r.denominator);
      result.reduceFraction();
      return result;
  }
  
  RationalNumber RationalNumber::operator+(int x)
  {
      RationalNumber result(numerator * x,denominator);
      return result;
  }
  </code></pre>
  
  <p>So here I have a class that is meant to represent rational numbers with overloaded operators that are intended for the purpose of carrying out arithmetic. However when in a main class performing the following:</p>
  
  <pre><code>RationalNumber medianCalculator(std::vector&lt;RationalNumber*&gt; &amp;listOfRationalNumbers)
  {
      std::sort(listOfRationalNumbers.begin(),listOfRationalNumbers.end());
      if(!(listOfRationalNumbers.size() % 2)){
          return ((RationalNumber(*listOfRationalNumbers.at((listOfRationalNumbers.size()/2) +1)) + (RationalNumber(*listOfRationalNumbers.at(listOfRationalNumbers.size()/2))) / 2));
      } else {
          return RationalNumber(*listOfRationalNumbers.at(listOfRationalNumbers.size() +1));
      }
  }
  </code></pre>
  
  <p>First of all, it seems to generate an out of range exception, but more importantly it seems like operator overloading hasn't worked as the std::sort call doesn't seem to work or the arithmetic.</p>