title: invalid use of non-static member function
body: <p>I have something like this: </p>
  
  <pre><code>class Bar
        {
        public:
          pair&lt;string,string&gt; one;
          std::vector&lt;string&gt; cars;
          Bar(string one, string two, string car);
        };
  
  class Car
        {
        public:
          string rz;
          Bar* owner;
          Car(string car, Bar* p);
        };
  
  class Foo
         {
           public:
            Foo  ( void );
            ~Foo  ( void );
            int Count ( const string &amp; one, const string &amp;  two) const;
            int comparator (const Bar &amp; first, const Bar &amp; second) const;            
              std::vector&lt;Bar&gt; bars;
         };
  
  int Foo::comparator(const Bar &amp; first, const Bar &amp; second) const{
    return first.name &lt; second.name;
  }
  
  int Foo::Count  ( const string &amp; one, const string &amp; two ) const{
    int result=0;
    Bar mybar = Bar( one, two, "" );
    std::vector&lt;Bar&gt;::iterator ToFind = lower_bound(bars.begin(), bars.end(), mybar, comparator);
    if (ToFind != bars.end() &amp;&amp; ToFind-&gt;one == mybar.one ){
      result = ...
    }
    return result;
  }
  </code></pre>
  
  <p>The method <code>Foo::Count</code> should use <code>std::lower_bound()</code> to find element in <code>vector&lt;Bar&gt;</code> according to pair of two strings. 
  Now the part which doesn't work. To <code>lower_bound()</code> I'm providing method <code>comparator()</code>. I thought it was okay, but g++ says: </p>
  
  <pre><code>c.cpp: In member function ‘int Foo::Count(const string&amp;, const string&amp;) const’:
  c.cpp:42:94: error: invalid use of non-static member function
  std::vector&lt;Bar&gt;::iterator ToFind = lower_bound(bars.begin(), bars.end(), mybar, comparator);
  </code></pre>
  
  <p>And the method <code>Count()</code> must stay <code>const</code>...</p>
  
  <p>I'm quite new to C++ because I'm forced to learn it. </p>
  
  <p>Any ideas?</p>