I am really appreciated if someone explain the meaning of line 10 in the following snippet to me. If operator is a member function of comp so why there are two pair of parenthesis in front of the operator ?!.
Thanks in advance,
A.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Student{
public:
int num;
string name;
};
class Comp
{
public:
booloperator()(Student s1, Student s2)
{
if(s1.num < s2.num )
returntrue;
elsereturnfalse;
}
};
it looks like you could use a overloaded stream operator to have a similar outcome. at least in the article it does. not the code above.
I dont like what the example above is doing. i just wouldnt use that particular operator in that way. i think id try and use a template instead. but im just a beginner so I make mistakes.