473,656 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1905
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
3479
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 non-zero index is returned. Below is my attempt, which generates compiler errors: namespace Reference {
1
2035
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
1675
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
1981
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 in only objects of class B and skip over the objects of class C. To complicate things, I'm using the vector position (index) as an argument in the invoked member function. It is possible to move the position into the object by adding a data...
4
1860
by: Lionel B | last post by:
Greetings, The following code: <code> template<typename T> class A { protected:
6
4401
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 same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
3
1448
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 the end ). class Cgroup_info: group_name = "" count = "0" #last time checked and processed/retrieved first = "0" last = "" retrieval_type = "" # allways , ask( if more than some limit), none date_checked = ""
6
5163
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 definitions static const char A; };
31
1962
by: huili80 | last post by:
Say I have two classes: class A { public: int x; }; class B {
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.