Hash function for custom class

class student{

public:

string firstname;

string lastname;

string rollno;

student(string f, string l; string no){

fistname= f;

lastname= l;

rollno = no;

}

bool operator == (const student & s) const {

return rollno == s.rollno ? true : false;

}

};

class hashfn{

public:

size_t operator() (const student &s) const{

return s.firstname.length() + s.lastname.length();

}

};

in the above class how does the bool operator funcion works could you please give an example how to use this in main function.

@princeguptaa it works in internal implementation of hashmap
you don’t have to use it explicitly, this is used to compare objects with collision.

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.