473,473 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

enum scope

Hi,

Do enumerators have scope?

class A
{
};
enum E {A, B, C};
int main()
{
E e = E::A;
}

Can ::A be distinguished from E::A?
Oct 15 '05 #1
2 6896
"vsgdp" <sp**@void.com> wrote in message
news:zi04f.2519$i%.522@fed1read07
Hi,

Do enumerators have scope?

class A
{
};
enum E {A, B, C};
int main()
{
E e = E::A;
}

Can ::A be distinguished from E::A?


There is no such thing as E::A. Enum values do have scope, but what that
means is the following:

enum Outer {A=0};

int main()
{
enum Inner {A=1};
int x = A; // x is 1, not 0
}
--
John Carson

Oct 15 '05 #2
vsgdp wrote:
Hi,

Do enumerators have scope?

class A
{
};
enum E {A, B, C};
int main()
{
E e = E::A;
}

Can ::A be distinguished from E::A?

The enumerators have the scope of where the enum is declared. In
this case at namespace scope. The class A and the enumerator A
are in the same namespace scope.

You could wrap a namespace around your enumerator if you wanted
differentiate:
class A ;
namespace E {
enum T { A, B, C };
};

E::T e = E::A;
Oct 16 '05 #3

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

Similar topics

5
by: pembed2003 | last post by:
Hi all, I am reading the book "C How to Program" and in the chapter where it discuss scope rule, it says there are four scopes for a variable: function scope file scope block scope...
8
by: Craig Klementowski | last post by:
All, I've installed the VS 2005 Beta 1 and was trying to build our current product. I get a compile error when enum value is specified with classname::enumname::enumvalue. Seems the compiler...
7
by: moondaddy | last post by:
I want to create a public enum that can be used throughout a project. I created an enum like this in a module: Public Enum ParentType Project = 0 Stage = 1 VIP = 2 Func = 3 Equipment = 4...
10
by: Randy | last post by:
Hi, Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h. ...
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
13
by: toton | last post by:
Hi, I have some enum (enumeration ) defined in some namespace, not inside class. How to use the enum constant's in some other namespace without using the whole namespace. To say in little...
1
by: wenmang | last post by:
Hi, I encountered some legacy codes with multiple definitions for some symbols in term of enum(global naemspace pollution). How can I enforce the scope of an enum? e.g., enum MyEnum { OK };...
3
by: dev_15 | last post by:
Hi, I have this problem that i want to use an enum as a return value of a private method in my class, but compiler won't let me use as such Code here: class CDisplayUtil { public: enum...
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
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
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...
0
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,...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.