Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > member name lookup

Reply
Thread Tools

member name lookup

 
 
Fraser Ross
Guest
Posts: n/a
 
      12-20-2007
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

 
Reply With Quote
 
 
 
 
jalina
Guest
Posts: n/a
 
      12-20-2007
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.
>
>
>

 
Reply With Quote
 
 
 
 
Fraser Ross
Guest
Posts: n/a
 
      12-20-2007
It must be senseless. Defect report 39 has changed it.

Fraser.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      12-20-2007
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
qualified member name lookup vanyacpp@gmail.com C++ 3 09-18-2012 07:05 AM
class member name lookup issues ZMZ C++ 1 01-20-2011 09:33 AM
Make a python property with the same name as the class member name Ravi Python 1 02-27-2009 04:43 PM
Overload lookup of pointer-to-member jknupp@gmail.com C++ 11 07-13-2008 09:00 PM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM



Advertisments