error C2064: term does not evaluate to a function taking 1 arguments
<pre><code>class Student {
    // ...
    bool Graduate() { return m_bGraduate; }
    // ...
};

class School {
    vector&lt;Student*&gt; m_vecStudents;

    void DelAndNullify(Student* &amp;pStd);
    void Fun1();
};

void School::DelAndNullify(Student* &amp;pStd)
{
    if ( (pStd != NULL) &amp;&amp; (pStd-&gt;Graduate()) )
    {
        delete pStd;
        pStd = NULL;
    }
}

void School::Fun1()
{
    for_each(m_vecStudents.begin(), m_vecStudents.end(), mem_fun(&amp;School::DelAndNullify));
}
</code></pre>

<blockquote>
  <p>Error 1   error C2064: term does not evaluate to a function taking 1 arguments    C:\Program Files\Microsoft Visual Studio 10.0\VC\include\algorithm  22  1   Simulation</p>
</blockquote>

<p>Why do I get this error?</p>

<hr>

<h2>updated</h2>

<p>change <code>Student</code> to <code>pStd</code></p>

<hr>

<h2>updated // algorithm file</h2>

<pre><code>template&lt;class _InIt, class _Fn1&gt; inline
_Fn1 _For_each(_InIt _First, _InIt _Last, _Fn1 _Func)
{
    // perform function for each element
    for (; _First != _Last; ++_First)
        _Func(*_First); // &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this line!
    return (_Func);
}
</code></pre>

<p>BTW, if I define the <code>DelAndNullify</code> as <code>static</code> then the following line passes the compiler</p>

<pre><code>for_each(m_vecStudents.begin(), m_vecStudents.end(), ptr_fun(&amp;School::DelAndNullify));
</code></pre>

<hr>

<h2>Updated 05/09/2012</h2>

<pre><code>#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;functional&gt;
#include &lt;boost/bind.hpp&gt;

class Student {
public:
    Student(int id, bool bGraduate) : m_iID(id), m_bGraduate(bGraduate) {}
    bool Graduate() const { return m_bGraduate; }
private:
    int  m_iID;
    bool m_bGraduate;
};

class School {
public:
    School(int numStudent)
    {
        for (int i=0; i&lt;numStudent; ++i)
        {
            m_vecStudents.push_back(new Student(i+1, false));
        }
    }

    ~School() 
    {   
        // deallocate the allocated student resource to prevent memory leak!
    }

    void DelAndNullify(Student* &amp;pStd);
    void Fun1();

private:
    std::vector&lt;Student*&gt; m_vecStudents;

};

void School::DelAndNullify(Student* &amp;pStd)
{
    if ( (pStd != NULL) &amp;&amp; (!pStd-&gt;Graduate()) )
    {
        delete pStd;
        pStd = NULL;
    }
}

void School::Fun1()
{   // http://stackoverflow.com/questions/6065041/error-c2064-term-does-not-evaluate-to-a-function-taking-1-arguments
    std::for_each(m_vecStudents.begin(), m_vecStudents.end(), std::bind1st(std::mem_fun(&amp;School::DelAndNullify), this));
    //boost::bind(&amp;School::DelAndNullify, this, _1);
}

int main(int /*argc*/, char* /*argv*/[])
{
    School school(10);
    school.Fun1();
    return 0;
}
</code></pre>

<blockquote>
  <p>Error 1   error C2535: 'void std::binder1st&lt;_Fn2>::operator ()(Student
  *&amp;) const' : member function already defined or declared  c:\Program Files\Microsoft Visual Studio 10.0\VC\include\xfunctional    299</p>
</blockquote>
