title: Overloading less than operater with different types
body: <p>I'm trying to overload the less than operator in order to use vector::lower_bound to find the closest/nearest number in a vector of type ClassA to a given double.
  I can get it to work if i give it 2 instances of ClassA to compare but can't with different types. </p>
  
  <p>I have the following code</p>
  
  <pre><code>double ClassB::findNearest()
  {
       std::vector&lt;ClassA&gt; vec;
       std::vector&lt;ClassA&gt;::iterator low;
       low = std::lower_bound(vec.begin(),vec.end(), 20.0);
  
       if (low == vec.end())
       {
            return -1;
       }
       return *low;
  }
  </code></pre>
  
  <h1>-----------------------------------------------------</h1>
  
  <pre><code>class ClassA
  {
  public:
     ClassA(void);
     virtual ~ClassA(void);
  
     double one;
     double two;
  
      inline friend bool operator&lt; ( const ClassA &amp;cC1, const double &amp;cC2)
      { 
           return cC1.one &lt; cC2 ;
      };
  };
  </code></pre>
  
  <p>i get the error:
  binary '&lt;' : no operator found which takes a left-hand operand of type 'const double' (or there is no acceptable conversion)</p>
  
  <p>... and i don't know why when i've overloaded the operator from right to left. Why do i need to go the other way?</p>
  
  <p>Many Thanks</p>
  
  <p>Alex</p>