Name lookup - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Name lookup

From cppreference.com
< cpp‎ | language

Name lookup is the procedure by which a name, when encountered in a program, is associated with the declaration that introduced it.

For function names, name lookup can associate multiple declarations with the same name, and may obtain additional declarations from argument-dependent lookup. Template argument deduction may also apply, and the set of declarations is passed to overload resolution, which selects the declaration that will be used. Member access rules, if applicable, are considered only after name lookup and overload resolution.

For all other names (variables, namespaces, classes, etc), name lookup must produce a single declaration in order for the program to compile.

For example, to compile std::cout << std::endl;, the compiler performs:

- unqualified name lookup for the name `std`, which finds the declaration of namespace std in the header `<iostream>`
- qualified name lookup for the name `cout`, which finds a variable declaration in the namespace `std`
- qualified name lookup for the name `endl`, which finds a function template declaration in the namespace `std`
- argument-dependent lookup for the name `operator <<`, which finds multiple function template declarations in the namespace std

### [edit] Types of lookup

If the name appears immediately to the right of the scope resolution operator `::` or possibly after `::` followed by the disambiguating keyword `template`, see

- Qualified name lookup

Otherwise, see

- Unqualified name lookup

  - (which, for function names, includes Argument-dependent lookup)

### [edit] See also

- Scope
- Argument-dependent lookup
- Template argument deduction
- Overload resolution

C documentation for Lookup and name spaces

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/language/lookup&oldid=78339"