Non-static function as parameter to another function in C++
<p>I've made a class <code>student</code> with subclass <code>comparator</code>. Constructor of <code>comparator</code> takes one argument called <code>cmp_mode</code> that specifies how we should compare students.</p>

<pre><code>class student
{
public:
    std::string name;
    int course, group;

    student(std::string name,
            int course,
            int group): name(name)
    {
        this-&gt;course = course;
        this-&gt;group = group;
    }

    enum cmp_mode
    {
        NAME,
        COURSE,
        GROUP
    };

    class comparator
    {
        cmp_mode mode;

    public:
        comparator(cmp_mode mode)
        {
            this-&gt;mode = mode;
        }

        bool compare(student s1, student s2)
        {
            if (mode == NAME)
                return s1.name &lt; s2.name;
            else if (mode == COURSE)
                return s1.course &lt; s2.course;
            else if (mode == GROUP)
                return s1.group &lt; s2.group;
            else
                throw "Oh god! We can't compare variables using these keys!";
        }
    };

};
</code></pre>

<p>Also, I've created a <code>list</code> of <code>students</code> and now I want to sort this list using comparator subclass. </p>

<pre><code>std::list&lt;student&gt; l;

student st1("Anya", 2, 5);
student st2("Misha", 4, 2);
student st3("Yasha", 1, 3);

l.push_back(st1);
l.push_back(st2);
l.push_back(st3); 

student::comparator by_group(student::GROUP);

l.sort(by_group.compare);
</code></pre>

<p>But I'm getting the following error.</p>

<pre><code>ERROR: Reference to non-static member function must be called.
</code></pre>

<p>So what should I do? How can I adjust sorting in the better way?</p>
