title: Correct Way to Define a Predicate Function in C++
body: <p>I'm trying to write predicate function for use with STL algorithms. I see that they are two ways to define a predicate:  </p>
  
  <p>(1) Use a simple function as below:  </p>
  
  <pre><code>bool isEven(unsigned int i)   
  { return (i%2 == 0); }
  
  std::find_if(itBegin, itEnd, isEven); 
  </code></pre>
  
  <p>(2) Use the operator() function as below: </p>
  
  <pre><code>class checker {  
  public:  
    bool operator()(unsigned int i)  
    { return (i%2 == 0); }  
  }; 
  
  std::find_if(itBegin, itEnd, checker); 
  </code></pre>
  
  <p>I have more use for the second type as I usually would like to create a predicate object with some members in it and use them in the algorithm. When I add the same isEven function inside checker and use it as a predicate, I get an error:<br>
  3. Syntax which gives error: </p>
  
  <pre><code>class checker { 
      public: 
         bool isEven(unsigned int i) 
         { return (i%2 == 0); }
  }; 
  
  checker c; 
  std::find_if(itBegin, itEnd, c.isEven); 
  </code></pre>
  
  <p>Calling c.isEven gives an error during compilation saying undefined reference to some function. Can someone explain why 3. is giving error? Also, I would appreciate any pointers to read about predicate and iterator basics.</p>