I am trying to sort a list<CMail>
( where CMail is some object, not important for purpose of this question ). Now, I'd like to sort it.
I am aware that list has a sort() function, which either uses standard operator< etc., or given compare function. And I do have such a function.
my function
bool comp( const CMail & x ) const;
returns, if we do consider a.comp(b); , true if a < b, and false otherwise. This function is also part of CMail class and therefore CMail namespace.
Now, I'd like to use this sorting function, and I'm using
temp.sort( CMail::comp );
where temp is a
list<CMail> temp;
But, compiler doesnt let me, saying
error: invalid use of non-static member function ‘bool CMail::comp(const CMail&) const’
does anyone see where the problem could be? Thanks in advance :)