c++ - Why function fun is not qualified for ADL? -


i have simple namespace, has 1 variable , 1 function. in main try call function without namespace qualifier, , variable namespace qualifier.

namespace sam {     int p = 10;     void fun(int)     {         cout<<"fun gets called";     } }   int main() {      fun(sam::p);//why sam::fun not called?     return 0; } 

i not able call fun, why not qualified adl (argument-dependant name lookup)?

i getting following error in visual studio.

'fun': identifier not found

if use sam::fun, works.

adl adopted type, not variable, e.g.

namespace sam {     struct p {};     void fun(p)     {         cout<<"fun gets called";     } }   int main() {     sam::p p;     fun(p);     return 0; } 

in c++ programming language, argument-dependent lookup (adl), or argument-dependent name lookup, applies lookup of unqualified function name depending on types of arguments given function call.

reference: argument-dependent name lookup


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -