Doubt regarding Set STL Quiz

Q1)Read the following code :
struct comp
{
bool operator() (unsigned int x, unsigned int y) {
return (x % 10) < (y % 10);
}
}

set < unsigned int, comp > mySet = {9, 12};
for ( int x : mySet) cout << x << ' ';

What is the output? What is the maximum possible size of mySet?

  1. depends upon the memory available, output is 12 9
  2. 10^8 , output is 12 9
  3. 10^1 , output is 12 9
  4. 10^2 , output is 9 12
    Doubt: Why the maximum size is 10^1 but When i use max_size() it shows a int greater than 10 digits
    Q2)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.
    1)bool operator () (student x, student y)
    2)bool operator () (const student& x, const student& y)
    3)bool operator () (student& x, const student& y)
    4)None of these
    Doubt: Why option 3 is correct?

if we pass arguments to functors then if the argument is passed by refernce then they should be const &name , else dont send using reference

so 3rd option is passed by reference but not 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.