473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

member name lookup

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

Dec 20 '07 #1
3 1893
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.
Dec 20 '07 #2
It must be senseless. Defect report 39 has changed it.

Fraser.

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

Dec 20 '07 #3
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
Dec 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas Matthews | last post by:
Hi, How do I create a const table of pointers to member functions? I'm implementing a Factory pattern (or jump table). I want to iterate through the table, calling each member function until a...
1
by: solartimba | last post by:
If I have a class like: class cExample { private: string name; int id; } and I have a vector of these objects vector<cExample> v.
10
by: Gianni Mariani | last post by:
While digging for a work around for a VC++7.1 compiler bug I came to find an interesting thing about pointer to member conversions. struct A { int a; }; struct B : A
3
by: Mark Turney | last post by:
Problem: I have a vector full of two different derived class objects (class B and class C) that are derived from the same base class A. I want to loop through vector and invoke a member function...
4
by: Lionel B | last post by:
Greetings, The following code: <code> template<typename T> class A { protected:
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
3
by: Sambo | last post by:
By accident I assigned int to a class member 'count' which was initialized to (empty) string and had no error till I tried to use it as string, obviously. Why was there no error on assignment( near...
6
by: mathieu | last post by:
Hi there I am trying to provide a lookup from two 'int's into a char array, something like this: template <int g, int estruct Lookup; template <struct Lookup<0,0{ // some typedef + enums...
31
by: huili80 | last post by:
Say I have two classes: class A { public: int x; }; class B {
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.