Re: Can I refer to members of an enumeration without using ::?

From: Swampmonster (swampmonster_at_der-ball-ist-rund.net)
Date: 12/14/04


Date: Tue, 14 Dec 2004 02:44:35 +0100

Howard wrote:
> "Xenos" <dont.spam.me@spamhate.com> wrote in message
> news:cpkmpd$9o02@cui1.lmms.lmco.com...
>
>>"Xenos" <dont.spam.me@spamhate.com> wrote in message
>>news:cpkgt0$9o01@cui1.lmms.lmco.com...
>>
>>>"Howard" <alicebt@hotmail.com> wrote in message
>>>news:oejvd.1086496$Gx4.129954@bgtnsc04-news.ops.worldnet.att.net...
>>>
>>>>But yes, it's legal C++. The name of an enumeration is not required
>>>>for
>>>>resolution, except in cases where you have members of different
>>>
>>>enumerations
>>>
>>>>having the same name. Such as:
>>>>
>>>>enum enumABC { eMin, eA, eB, eC, eMax };
>>>>enum enumXYZ { eMin, eX, eY, eZ, eMax };
>>>>
>>>>In that case, you'd need to specify which enumeration you were
>>>>referring
>>>
>>>to
>>>
>>>>(when referring to eMin or eMax). (But in such a case, putting them in
>>>>separate namespaces is also probably a good idea.)
>>>>
>>
>>I just tried defining the above enums in a test program, and g++
>>complained
>>because they contained the same identifier names for the elements. It
>>this
>>really legal?
>
>
> Apparently I was mistaken on this point. When both names are visible in the
> current scope(s), this would amount to illegal name overloading, and won't
> compile. They'd have to be in different namespaces (also, I think, within
> separate classes would work?)
>
> So my example won't compile. If, however, enumXYZ was in namespace nsXYZ,
> then you could use it by specifying nsXYZ::eMin, for example, (which is what
> I suggested was probably better to do anyway). But you don't have to
> specify the name of the enumeration in order to access its members. This
> fact (that the names of the members are not restricted to having the enum
> type itself specified) is exactly what makes it illegal to have the same
> member name in multiple enums in the same scope: both names are visible at
> the scope level, and therefore you can't have two of them declared there!
>
> Sorry about that!
>
> -Howard
>

AFAIK you can't even qualify a "member of an enum" (correct term?
"enumerator"?) with the enum's name :-)

bye,
'monster



Relevant Pages

  • Re: Windows Version numbers for Windows 2008
    ... to specify the size of the structure. ... backwards compatibility among versions of Windows. ... Also, if I add extra members to the structure, like ... Pointer to an OSVERSIONINFO data structure that the function ...
    (microsoft.public.vb.winapi)
  • Re: Help using Dsget to list compuetrs in group
    ... Either by command line or in ADUC query tool. ... the members (unless you bind to each member in a script and check the ... You do need to specify the full Distinguished Name of the group. ... the computer object is already in the specified OU. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Help using Dsget to list compuetrs in group
    ... When you enumerate members of a group, there is no way tell the class of the ... need to specify the full Distinguished Name of the group. ... I do this so the program can tell if the computer object is ... Dim objRootDSE, strDNSDomain, adoCommand, adoConnection ...
    (microsoft.public.windows.server.active_directory)
  • Re: enum
    ... According to my knowledge,enum members are integers and they are ... Its means,enum members are given memory then how come i am getting 4 ...     return 0; ... enum statement generates no code and allocates no storage. ...
    (comp.lang.c)
  • Re: Removing members from multiple groups in a OU
    ... Const ADS_PROPERTY_CLEAR = 1 ... For Each objGroup In objOU ... But I need to remove all members not just one in diffrent groups under one ... ' Specify the Distinguished Name of the user. ...
    (microsoft.public.windows.server.scripting)