Sets STL Comparator function

Q8. Sets STL#8
Study the following code carefully.

struct student{
    string name;
    float cgpa;
    student(string name, float cgpa){
        this -> name = name;
        this -> cgpa = cgpa;
    }
};

struct comp{
    bool operator () (const student& x, student y) {
        return x.name < y.name;
    }
};

set < student, comp > batch;
The above code compiles successfully. Choose which of the following declarations of the function operator () will give a compilation error.

When you are sending by reference (by using & operator) to a custom comparator it must be sent with const type. const means that it will become immutable.
bool operator () (student& x, const student& y) will give error as the first parameter is not with a const.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.