title: Use STL find_if() to find a specific object in a Vector of object pointers
body: <p>I'm trying to find a certain object in a Vector of object pointers.
  Lets say these are my classes.</p>
  
  <pre><code>// Class.h
  class Class{
  public:
      int x;
      Class(int xx);
      bool operator==(const Class &amp;other) const;
      bool operator&lt;(const Class &amp;other) const;
  };
  
  // Class.cpp
  #include "Class.h"
  Class::Class(int xx){
      x = xx;
  }
  
  bool Class::operator==(const Class &amp;other) const {
      return (this-&gt;x == other.x);
  }
  
  bool Class::operator&lt;(const Class &amp;other) const {
      return (this-&gt;x &lt; other.x);
  }
  
  // Main.cpp
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include "Class.h"
  using namespace std;
  
  int main(){
      vector&lt;Class*&gt; set;
      Class *c1 = new Class(55);
      Class *c2 = new Class(34);
      Class *c3 = new Class(67);
      set.push_back(c31);
      set.push_back(c32);
      set.push_back(c33);
  
      Class *c4 = new Class(34);
  }
  </code></pre>
  
  <p>Lets say that for my purposes, 2 objects of class are equal if their 'x' values are the same. So in the above code, i'd like to use a predicate in the STL find_if() method to be able to 'find' c4 in the vector.</p>
  
  <p>I can't seem to get a predicate to work. I'm basing my find predicate on the predicate I wrote for sorting.</p>
  
  <pre><code>struct less{
      bool operator()(Class *c1, Class *c2){return  *c1 &lt; *c2;}   
  };
  sort(set.begin(), set.end(), less());
  </code></pre>
  
  <p>This sorting predicate works fine. So I adapted it to use for finding</p>
  
  <pre><code>struct eq{
      bool operator()(Class *c1, Class *c2){return  *c1 == *c2;}  
  };
  </code></pre>
  
  <p>Why won't this predicate work?
  What is the better way of writing a predicate for this?</p>
  
  <p>Thanks</p>