In class hashfn why we have overloaded the operator()
basic code:-
size_t operator()(const student &s)const{
}
In class hashfn why we have overloaded the operator()
basic code:-
size_t operator()(const student &s)const{
}
hello @shashankmaheshwari054
we cant hash user defined class directly in map without defining the hash function because compiler dont know how to hash user defined classes.
thats why its user responsibility to write functor and feed logic of hashfunction inside it and then pass it as third argument of map
why are we writing the const in the function
we dont want this function to make any change with the passed object thats why 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.