If the nested-name-specifier of a qualified-id nominates a class, the name specified after the nested-name-specifier is looked up in the scope of the class ([class.member.lookup]), except for the cases listed below. The name shall represent one or more members of that class or of one of its base classes (Clause [class.derived]). [ Note: A class member can be referred to using a qualified-id at any point in its potential scope ([basic.scope.class]). — end note ] The exceptions to the name lookup rule above are the following:
a destructor name is looked up as specified in [basic.lookup.qual];
a conversion-type-id of a conversion-function-id is looked up in the same manner as a conversion-type-id in a class member access (see [basic.lookup.classref]);
the names in a template-argument of a template-id are looked up in the context in which the entire postfix-expression occurs.
the lookup for a name specified in a using-declaration ([namespace.udecl]) also finds class or enumeration names hidden within the same scope ([basic.scope.hiding]).
In a lookup in which function names are not ignored33 and the nested-name-specifier nominates a class C:
if the name specified after the nested-name-specifier, when looked up in C, is the injected-class-name of C (Clause [class]), or
in a using-declaration ([namespace.udecl]) that is a member-declaration, if the name specified after the nested-name-specifier is the same as the identifier or the simple-template-id's template-name in the last component of the nested-name-specifier,
the name is instead considered to name the constructor of class C. [ Note: For example, the constructor is not an acceptable lookup result in an elaborated-type-specifier so the constructor would not be used in place of the injected-class-name. — end note ] Such a constructor name shall be used only in the declarator-id of a declaration that names a constructor or in a using-declaration. [ Example:
struct A { A(); }; struct B: public A { B(); }; A::A() { } B::B() { } B::A ba; // object of type A A::A a; // error, A::A is not a type name struct A::A a2; // object of type A
— end example ]
A class member name hidden by a name in a nested declarative region or by the name of a derived class member can still be found if qualified by the name of its class followed by the :: operator.
Lookups in which function names are ignored include names appearing in a nested-name-specifier, an elaborated-type-specifier, or a base-specifier.