https://ide.codingblocks.com/s/441686 not able to understand the working of hashmap for custom classes?
also code is not working’
https://ide.codingblocks.com/s/441686 not able to understand the working of hashmap for custom classes?
also code is not working’
hello @CODER_JATIN
check ur updated code here->https://ide.codingblocks.com/s/441723
it was a small syntax error.
map jo hai wo custom class ko apne aap hash nahi kar pata isiliye hume apna khud ka hash function bana ke dena hota hai.
is code me hum wahi kar rahe hai,humne functor banaya hai jisme humne hashing ka logic likha hai.
aur wahi same functor humne map ke third argument me pass kiya hai taaki map ko pata chal jayeg ki hame custom class ko kaise hash karna hai.
BHAIYA , hash function ham apne hisab se kuch bhi bna skte hai , jese hamne is code mai hashfunction se firstname or lastname ki length as a index of hashtable return kra rhe hai
hashfunction ham bhaiya roll no ke basis pe bhi bna skte they naa?
ha . . . . . . . . .
or bhaiya ye jo == operator hamne overload kiya hai , ye bhi smjhado ek baar?
compiler ko nahi pata ki do student object ko kaise compare karna hai isiliye hum apna khud ka logic likh ke batana hota hai.
isiliye humne == operator ko overload kiya hai aur usme compairison logic likha hai.
jab kabhi bhi tum student1==student2 karoge tab operator== wala code chal jayega ka
okay okay bhaiya , to ye jo hamne operator overload kia == , ye hmara is code mai searching mai kaam aayega naa?
ha use liye kaam aayega
okay bhaiya , or jo hmara functor hota hai vo bool ke alawa kisi or type ka bhi ho skta hai?
ha bhai kisi aur bhi dataype ka ho sakta hai,
hum jaydatar comparision ke liye functor banate hai isiliye bool return karte hai agar kisi kuch aur kaam karega functor to uska return type bhi kuch aur hoga
okay sir ji , thank you so much
yaar ye sir ji mat bola karo bhaiya sahi rahega
Okay bhaiya , thank you so much
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.