Namespaces
Variants
Views
Actions

Talk:cpp/language/unqualified lookup

From cppreference.com

The code snippet: struct V { int v; };
struct A {
        int a;
        static int s;
        enum { e };
};
struct B : A, virtual V { };
struct C : A, virtual V { };
struct D : B, C { };
 
void f(D& pd) {
        ++pd.v; // OK: only one v because only one virtual base subobject
        ++pd.s; // OK: only one static A::s, even though found in B and in C
        int i = pd.e; // OK: only one enumerator A::e, even though found in B and C
        ++pd.a; // error, ambiguous: A::a in B and A::a in C
}

under the section Member function definition of the page [1].

I think there is a mistake on the above snippet. The comment says

// OK: only one static A::s, even though found in B and in C

but It's not ok. You can't change the static variables using the instance. Because static variables are not the member's of instances they are the member's of the class or struct, which retains state information between call that's why they are allocated in .DATA or .BSS

--Appey (talk) 08:32, 28 January 2016 (PST)

In C++ you can. T. Canens (talk) 09:27, 28 January 2016 (PST)

[edit] Unqualified lookup of dependent name

I'm confused as to whether there is any such thing as unqualified lookup of a dependent name. Is there an obvious example?

there is one in this very page, where it says
f(t);    // dependent name: lookup postponed
for more detail, cpp/language/dependent_name#Dependent_names needs some work --Cubbi (talk) 06:29, 30 June 2016 (PDT)