Std::getline not needed? HELP

my code seems to compile and run with no errors or bugs but i’m wondering if there is an underlying reason why Ben said to use it in these instances?
Capture

Hi @Barry117, so this is possible because of the Argument-Dependent Lookup a.k.a. ADL
or Koeing Lookup. Basically it works like this, getline() should not work, but with the ADL the function look inside of it owns arguments getline(std::cin, response) and find the std:: there, when this happens, inside the std:: exists the function getline(). So now getline() can use the std:: like this std::getline(). Got it? The link below can explain better then me. :stuck_out_tongue_closed_eyes:

see link :arrow_right: Argument-Dependent Lookup

2 Likes

That’s perfect your message was enough for me to understand : ) so basically in this instance as i’m using getline(std::cin, response); the std:: is picked up after the getline function. so the use of std:: in this context is purely cosmetic and makes the code easier to understand for someone who may have stumbled across the line.

I’m glad that I could help you understand.
See ya next time! Byee!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms