Why i need to use the const function in the Less Traits
<p>why i need to use the const function in the less traits? 
for example, why i must use const in Age or ID member function.</p>

<pre><code>    #include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;algorithm&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;set&gt;
using namespace std;
class Person
{
public:
    Person(int id, string name, int age):m_iID(id), m_strName(name), m_iAge(age){};
    int Age() const {return m_iAge;}
    int ID() const {return m_iID;}
    void Display();
    friend ostream&amp; operator&lt;&lt;(ostream&amp; out, Person&amp; person);
private:
    int m_iID;
    string m_strName;
    int m_iAge;

};
void Person::Display()
{
    cout&lt;&lt;m_iID&lt;&lt;" "&lt;&lt;m_strName&lt;&lt;" "&lt;&lt;m_iAge&lt;&lt;endl;
}
ostream&amp; operator&lt;&lt; (ostream&amp; out, Person&amp; person)
{
    out&lt;&lt;person.m_iID&lt;&lt;" "&lt;&lt;person.m_strName&lt;&lt;" "&lt;&lt;person.m_iAge&lt;&lt;endl;
    return out;
}

int SumPersonAge(int iSumAge, Person&amp; person)
{
    return iSumAge + person.Age();
}
template &lt;typename Type&gt;
void Display(Type t1)
{
    cout&lt;&lt;t1&lt;&lt;endl;
}

class LessPerson
{
public:
    template &lt;typename Type&gt;
    bool operator()(Type&amp; t1, Type&amp; t2)
    {
        return t1.ID() &lt; t2.ID();
    }
};

int main()
{
    set&lt;Person, LessPerson&gt; s1;
    Person p1(1234, "Roger", 23);
    Person p2(1235, "Razor", 24);
    s1.insert(p1);
    s1.insert(p2);
    for_each(s1.begin(), s1.end(), Display&lt;Person&gt;);
}
</code></pre>

<p>if i remove the const the keyword in Age or ID function, the compiler will report me Error  cannot convert 'this' pointer from 'const Person' to 'Person &amp;'.</p>
