member name lookup

Discussion in 'C++' started by Fraser Ross, Dec 20, 2007.

  1. Fraser Ross

    Fraser Ross Guest

    10.2/2 of the C++ standard says this:

    "The following steps define the result of name lookup in a class
    scope, C. First, every declaration for the name in the class and in
    each of its base class sub-objects is considered. A member name f in
    one subobject B hides a member name f in a sub-object A if A is a base
    class sub-object of B. Any declarations that are so hidden are
    eliminated from consideration. Each of these declarations that was
    introduced by a using-declaration is considered to be from each sub-
    object of C that is of the type containing the declaration designated
    by the using-declaration. If the resulting set of declarations are not
    all from sub-objects of the same type, or the set has a nonstatic
    member and includes members from distinct sub-objects, there is an
    ambiguity and the program is ill-formed...."


    I don't understand the sentence beginning with the word Each. Is it
    wrong?

    Fraser.



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    Fraser Ross, Dec 20, 2007
    #1
    1. Advertising

  2. Fraser Ross

    jalina Guest

    Fraser Ross a écrit :
    > 10.2/2 of the C++ standard says this:
    >
    > "The following steps define the result of name lookup in a class
    > scope, C. First, every declaration for the name in the class and in
    > each of its base class sub-objects is considered. A member name f in
    > one subobject B hides a member name f in a sub-object A if A is a base
    > class sub-object of B. Any declarations that are so hidden are
    > eliminated from consideration. Each of these declarations that was
    > introduced by a using-declaration is considered to be from each sub-
    > object of C that is of the type containing the declaration designated
    > by the using-declaration. If the resulting set of declarations are not
    > all from sub-objects of the same type, or the set has a nonstatic
    > member and includes members from distinct sub-objects, there is an
    > ambiguity and the program is ill-formed...."
    >
    >
    > I don't understand the sentence beginning with the word Each. Is it
    > wrong?
    >


    You lucky if this is the only sentence you don't understand in the C++
    standard.

    > Fraser.
    >
    >
    >
     
    jalina, Dec 20, 2007
    #2
    1. Advertising

  3. Fraser Ross

    Fraser Ross Guest

    It must be senseless. Defect report 39 has changed it.

    Fraser.



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    Fraser Ross, Dec 20, 2007
    #3
  4. Fraser Ross wrote:
    > 10.2/2 of the C++ standard says this:
    >
    > "The following steps define the result of name lookup in a class
    > scope, C. First, every declaration for the name in the class and in
    > each of its base class sub-objects is considered. A member name f in
    > one subobject B hides a member name f in a sub-object A if A is a base
    > class sub-object of B. Any declarations that are so hidden are
    > eliminated from consideration. Each of these declarations that was
    > introduced by a using-declaration is considered to be from each sub-
    > object of C that is of the type containing the declaration designated
    > by the using-declaration. If the resulting set of declarations are not
    > all from sub-objects of the same type, or the set has a nonstatic
    > member and includes members from distinct sub-objects, there is an
    > ambiguity and the program is ill-formed...."
    >
    >
    > I don't understand the sentence beginning with the word Each. Is it
    > wrong?


    struct A {
    void f();
    };

    struct B : A {
    void f(int);
    };

    struct C : B {
    void f(double);
    using B::f;
    };

    struct CC : B {
    void f(double);
    using A::f;
    };

    struct D : B {
    void f(char*);
    };

    int main() {
    C c;
    CC cc;
    D d;
    c.foo(2); // case 1
    cc.foo(); // case 2
    d.foo(); // case 3
    d.foo(2); // case 4
    }

    The lookup in case 1 and case 2 should consider 'foo' introduced into
    the scope of 'C' and 'CC', respectively, the former from 'B' and the
    latter from 'A'. That's what the sentence seems to say (to me at least).

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Dec 20, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    2,153
    Chris Uppal
    Mar 17, 2006
  2. Replies:
    11
    Views:
    949
  3. Ravi
    Replies:
    1
    Views:
    575
    Chris Rebert
    Feb 27, 2009
  4. ZMZ
    Replies:
    1
    Views:
    323
    Johannes Schaub (litb)
    Jan 20, 2011
  5. Replies:
    3
    Views:
    413
    Ivan Sorokin
    Sep 18, 2012
Loading...

Share This Page