cpp/language/lookup

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

For example, to compile, the compiler performs:
 * unqualified name lookup for the name, which finds the declaration of namespace std in the header
 * qualified name lookup for the name, which finds a variable declaration in the namespace
 * qualified name lookup for the name, which finds a function template declaration in the namespace
 * both for the name, which finds multiple function template declarations in the namespace , and qualified name lookup for the name , which finds multiple member function declarations in class std.

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

For all other names (variables, namespaces, classes, etc), name lookup can associate multiple declarations only if they declare the same, otherwise it must produce a single declaration in order for the program to compile. Lookup for a name in a scope finds all declarations of that name, with one exception, known as the "struct hack" or "type/non-type hiding": Within the same scope, some occurrences of a name may refer to a declaration of a class/struct/union/enum that is not a, while all other occurrences of the same name either all refer to the same variable, non-static data member, or enumerator, or they all refer to possibly overloaded function or function template names. In this case, there is no error, but the type name is hidden from lookup (the code must use to access it).

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

Otherwise, see
 * (which, for function names, includes )
 * (which, for function names, includes )