Overloading of operator == (hash function for custom class)

In the unordered map hash function for custom class I did not really understand why did we overload the == operator and what was the necessity of declaring that function as a constant as well??

it is necessary because == is defined only for primitive data types like int,float,char
but for user defined data types you have to declare your own == operator as compiler doesn’t know how to compare 2 students

The idea of const functions is not to allow them to modify the object on which they are called. It is recommended the practice to make as many functions const as possible so that accidental changes to objects are avoided.

i hope now both points clear to you.

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.