473,786 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

name conflicts in enum

Hello everyone,
Suppose I have two enums which has an item with the same names -- but
different values,

Expand|Select|Wrap|Line Numbers
  1. enum foo {
  2.  
  3. NAME = 100;
  4. }
  5.  
  6. enum goo {
  7.  
  8. NAME = 200;
  9. }
  10.  
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
thanks in advance,
George
Nov 2 '07 #1
6 1423
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,
Suppose I have two enums which has an item with the same names -- but
different values,

Expand|Select|Wrap|Line Numbers
  1. enum foo {
  2.           NAME = 100;
  3. }
  4. enum goo {
  5.           NAME = 200;
  6. }
  7.  

Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
thanks in advance,
George

Nov 2 '07 #2
BTW... this is a newsgroup for C++ CLI so I suppose that you're using it. You
can use 'enum class' instead of C++ enum. Enum class values don't have the
problem of scope visibility (present in C++ enum values).

Regards

--
Cholo Lennon
Bs.As.
ARG
"Cholo Lennon" <ch*********@ho tmail.comwrote in message
news:#c******** ******@TK2MSFTN GP04.phx.gbl...
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,
Suppose I have two enums which has an item with the same names -- but
different values,

Expand|Select|Wrap|Line Numbers
  1.  enum foo {
  2.  
  3.            NAME = 100;
  4.  }
  5.  
  6.  enum goo {
  7.  
  8.            NAME = 200;
  9.  }
  10.  
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
thanks in advance,
George


Nov 2 '07 #3
Thanks Cholo,
It works! Cool!
regards,
George

"Cholo Lennon" wrote:
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,
Suppose I have two enums which has an item with the same names -- but
different values,

Expand|Select|Wrap|Line Numbers
  1.  enum foo {
  2.  
  3.            NAME = 100;
  4.  }
  5.  
  6.  enum goo {
  7.  
  8.            NAME = 200;
  9.  }
  10.  
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
thanks in advance,
George


Nov 2 '07 #4
Hi Cholo,
Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.
regards,
George

"Cholo Lennon" wrote:
BTW... this is a newsgroup for C++ CLI so I suppose that you're using it. You
can use 'enum class' instead of C++ enum. Enum class values don't have the
problem of scope visibility (present in C++ enum values).

Regards

--
Cholo Lennon
Bs.As.
ARG
"Cholo Lennon" <ch*********@ho tmail.comwrote in message
news:#c******** ******@TK2MSFTN GP04.phx.gbl...
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,
>
>
Suppose I have two enums which has an item with the same names -- but
different values,
>
Expand|Select|Wrap|Line Numbers
  1.  enum foo {
  2.  >
  3.            NAME = 100;
  4.  }
  5.  >
  6.  enum goo {
  7.  >
  8.            NAME = 200;
  9.  }
  10.  
>
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
>
>
thanks in advance,
George


Nov 2 '07 #5
- microsoft.publi c.vc.language
- microsoft.publi c.vc.atl (for your question about COM)

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message news:CB******** *************** ***********@mic rosoft.com...
Hi Cholo,
Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.
regards,
George

"Cholo Lennon" wrote:
BTW... this is a newsgroup for C++ CLI so I suppose that you're using it. You
can use 'enum class' instead of C++ enum. Enum class values don't have the
problem of scope visibility (present in C++ enum values).

Regards

--
Cholo Lennon
Bs.As.
ARG
"Cholo Lennon" <ch*********@ho tmail.comwrote in message
news:#c******** ******@TK2MSFTN GP04.phx.gbl...
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.
>
Regards
>
--
Cholo Lennon
Bs.As.
ARG
>
>
"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,


Suppose I have two enums which has an item with the same names -- but
different values,

Expand|Select|Wrap|Line Numbers
  1.   enum foo {
  2.  
  3.             NAME = 100;
  4.   }
  5.  
  6.   enum goo {
  7.  
  8.             NAME = 200;
  9.   }
  10.  
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?


thanks in advance,
George
>
>

Nov 2 '07 #6
Thanks Cholo!
regards,
George

"Cholo Lennon" wrote:
- microsoft.publi c.vc.language
- microsoft.publi c.vc.atl (for your question about COM)

Regards

--
Cholo Lennon
Bs.As.
ARG
"George" <Ge****@discuss ions.microsoft. comwrote in message news:CB******** *************** ***********@mic rosoft.com...
Hi Cholo,
Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.
regards,
George

"Cholo Lennon" wrote:
BTW... this is a newsgroup for C++ CLI so I suppose that you're using it. You
can use 'enum class' instead of C++ enum. Enum class values don't have the
problem of scope visibility (present in C++ enum values).
>
Regards
>
--
Cholo Lennon
Bs.As.
ARG
>
>
"Cholo Lennon" <ch*********@ho tmail.comwrote in message
news:#c******** ******@TK2MSFTN GP04.phx.gbl...
You have to put them in different namespaces, otherwise the code doesn't
compile. If you do that, you can refer enum values using namespace name.

Regards

--
Cholo Lennon
Bs.As.
ARG


"George" <Ge****@discuss ions.microsoft. comwrote in message
news:88******** *************** ***********@mic rosoft.com...
Hello everyone,
>
>
Suppose I have two enums which has an item with the same names -- but
different values,
>
Expand|Select|Wrap|Line Numbers
  1.   enum foo {
  2.   >
  3.             NAME = 100;
  4.   }
  5.   >
  6.   enum goo {
  7.   >
  8.             NAME = 200;
  9.   }
  10.  
>
Are there any ways to specify whether I need to access NAME in foo or NAME
in goo?
>
>
thanks in advance,
George


>
>
>


Nov 3 '07 #7

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

Similar topics

7
1940
by: mcdonamw | last post by:
This may sound like a stupid stupid question and I figure it would b more "general" than pertaining to a specific Language. I'm using vb.net and I have a bunch of Const values in my program. can use them obviously by placing their names in place of values, henc the ideal behind using Const. My question is... is there a way to get the actual Variable name for specific value that is returned to me?
12
1800
by: christopherlmarshall | last post by:
Suppose you want to write a subclass of some existing class you are importing from a module you didn't write and that you don't want to study the internals of, and you want to define a data member i in your constructor. As in the following: from module1 import A class B(A):
2
1845
by: LoopyNZ | last post by:
Hi, (Access 97) I'm creating a query (QRY_SUMMARY) to join a query (QRY) to itself (QRY_1). I'm returning QRY.* and selected fields from QRY_1. With each field (field_name) I return from QRY_1 I'm appending "_1" to to the end to avoid name conflicts with the fields from QRY, i.e. "field_name" becomes "field_name_1".
5
6936
by: Alex Stevens | last post by:
Hi All, In the absence of any predefined standards, I was wondering how to name and implement my enum in a class. My dilema is: When I (for example) have an integer property in my class I'll use a class level variable called mintCount and the property sub accepts a variable called intCount and then assigns mintCount = intCount.
13
12393
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
5
4306
by: thetrueaplus | last post by:
Hey. I'm trying to make a couple of enums work, however mingW isn't compiling it because it says the previous declaration of none conflicts. is there a way to solve this? namespace Namespace { enum Gender // m or f {
6
34974
by: Rico | last post by:
Hello, I'm looking for a way to reference the string name of an enumerator. I know in VB.net you can do "MyEnum.ToString" and get the name instead of the integer value. Is there a way I can do something similar with an Enum created in Access? Alright, here is some air code to explain what I mean Public Enum MyEnum
5
7533
by: Sin Jeong-hun | last post by:
Hello. Speical folders, like Desktop, usually have different display names. For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want to get the this displayed name of a special folder but I can't find a suitable method. Environment.GetFolderPath() is to get the path not the name. There's no way provided the .NET BCL? I also tried to get it through Win32 API. I looked up the MSDN site...
0
9647
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
9492
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
10360
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
10163
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...
1
10108
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
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...
0
6744
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
5397
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
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.