c++ - How does the Compiler Know Whether to Call the const Overload? -


given string foo, when call:

auto bar = foo.begin(); 

there 2 overloads of string::begin. 1 returns string::iterator , other returns string::const_iterator. how can know type of bar? based on whether foo const or not?

is based on whether foo const or not?

yes

auto meant deducing exact type*


how select iterator type using auto variable? indirectly agrees answer.

*taken from: how const_iterator using auto?


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo