Problem with enum index 
Author Message
 Problem with enum index

Hi Guys

I created two enum and just saw something really strange, as I remember the
index of enum members will start from 0 by default and increment by one for
the rest of member.but in my enum for example CustomerField::enObjectID
index  instead of 1 is 0 (same index that it has in UnitField!!!) , anyone
has any idea what would be wrong> ,shouldn't they be unique?

here is my code

#pragma once

#include "stdafx.h"

namespace NewDL

{

    private __value enum UnitField
    {

    enObjectID, enUnitName, enAnimalCount, enUnitType, enUnitSubType1,

    enUnitSubType2, enUnitStatus

    };

    private __value enum CustomerField

    {

    enFirstName, enObjectID, enLastName, enAddress1, enAddress2, enCity,
enProvince, enCountry, enPostal_ZipCode, enPhone,

    enCell, enFax,{*filter*}il

    };

Quote:
}

Thanks in advace

Reza



Wed, 12 Jan 2005 07:03:35 GMT  
 Problem with enum index
int main()
{
    Console::WriteLine(NewDL::UnitField::enObjectID);
    Console::WriteLine(NewDL::CustomerField::enObjectID);
return 0;
Quote:
}

I get 0 and 1 outputted to the screen as expected
Maybe your code has something more involved?


Quote:
> Hi Guys

> I created two enum and just saw something really strange, as I remember
the
> index of enum members will start from 0 by default and increment by one
for
> the rest of member.but in my enum for example CustomerField::enObjectID
> index  instead of 1 is 0 (same index that it has in UnitField!!!) , anyone
> has any idea what would be wrong> ,shouldn't they be unique?

> here is my code

> #pragma once

> #include "stdafx.h"

> namespace NewDL

> {

>     private __value enum UnitField
>     {

>     enObjectID, enUnitName, enAnimalCount, enUnitType, enUnitSubType1,

>     enUnitSubType2, enUnitStatus

>     };

>     private __value enum CustomerField

>     {

>     enFirstName, enObjectID, enLastName, enAddress1, enAddress2, enCity,
> enProvince, enCountry, enPostal_ZipCode, enPhone,

>     enCell, enFax,{*filter*}il

>     };

> }

> Thanks in advace

> Reza



Wed, 12 Jan 2005 04:12:07 GMT  
 Problem with enum index
to be honest my program is far from running right now , but index number is
wrong  in tooltip text message in desing time , and it freak me out!! and I
didn't test it in run time.

thanks

Reza


Quote:
> int main()
> {
>     Console::WriteLine(NewDL::UnitField::enObjectID);
>     Console::WriteLine(NewDL::CustomerField::enObjectID);
> return 0;
> }
> I get 0 and 1 outputted to the screen as expected
> Maybe your code has something more involved?



> > Hi Guys

> > I created two enum and just saw something really strange, as I remember
> the
> > index of enum members will start from 0 by default and increment by one
> for
> > the rest of member.but in my enum for example CustomerField::enObjectID
> > index  instead of 1 is 0 (same index that it has in UnitField!!!) ,
anyone
> > has any idea what would be wrong> ,shouldn't they be unique?

> > here is my code

> > #pragma once

> > #include "stdafx.h"

> > namespace NewDL

> > {

> >     private __value enum UnitField
> >     {

> >     enObjectID, enUnitName, enAnimalCount, enUnitType, enUnitSubType1,

> >     enUnitSubType2, enUnitStatus

> >     };

> >     private __value enum CustomerField

> >     {

> >     enFirstName, enObjectID, enLastName, enAddress1, enAddress2, enCity,
> > enProvince, enCountry, enPostal_ZipCode, enPhone,

> >     enCell, enFax,{*filter*}il

> >     };

> > }

> > Thanks in advace

> > Reza



Wed, 12 Jan 2005 07:29:58 GMT  
 Problem with enum index
Can you look at the built assembly with ildasm and see what the metadata for
the class says?

Ronald


Quote:
> to be honest my program is far from running right now , but index number
is
> wrong  in tooltip text message in desing time , and it freak me out!! and
I
> didn't test it in run time.

> thanks

> Reza



> > int main()
> > {
> >     Console::WriteLine(NewDL::UnitField::enObjectID);
> >     Console::WriteLine(NewDL::CustomerField::enObjectID);
> > return 0;
> > }
> > I get 0 and 1 outputted to the screen as expected
> > Maybe your code has something more involved?



> > > Hi Guys

> > > I created two enum and just saw something really strange, as I
remember
> > the
> > > index of enum members will start from 0 by default and increment by
one
> > for
> > > the rest of member.but in my enum for example

CustomerField::enObjectID

- Show quoted text -

Quote:
> > > index  instead of 1 is 0 (same index that it has in UnitField!!!) ,
> anyone
> > > has any idea what would be wrong> ,shouldn't they be unique?

> > > here is my code

> > > #pragma once

> > > #include "stdafx.h"

> > > namespace NewDL

> > > {

> > >     private __value enum UnitField
> > >     {

> > >     enObjectID, enUnitName, enAnimalCount, enUnitType, enUnitSubType1,

> > >     enUnitSubType2, enUnitStatus

> > >     };

> > >     private __value enum CustomerField

> > >     {

> > >     enFirstName, enObjectID, enLastName, enAddress1, enAddress2,
enCity,
> > > enProvince, enCountry, enPostal_ZipCode, enPhone,

> > >     enCell, enFax,{*filter*}il

> > >     };

> > > }

> > > Thanks in advace

> > > Reza



Wed, 12 Jan 2005 04:53:40 GMT  
 Problem with enum index



Quote:
> to be honest my program is far from running right now , but index number
is
> wrong  in tooltip text message in desing time , and it freak me out!! and
I
> didn't test it in run time.

This is a tooltip problem. It isn't smart enough to figure out *which* enum
you are using, so it might very well show the wrong one.

Bo Persson

Quote:
> thanks

> Reza



> > int main()
> > {
> >     Console::WriteLine(NewDL::UnitField::enObjectID);
> >     Console::WriteLine(NewDL::CustomerField::enObjectID);
> > return 0;
> > }
> > I get 0 and 1 outputted to the screen as expected
> > Maybe your code has something more involved?



> > > Hi Guys

> > > I created two enum and just saw something really strange, as I
remember
> > the
> > > index of enum members will start from 0 by default and increment by
one
> > for
> > > the rest of member.but in my enum for example

CustomerField::enObjectID

- Show quoted text -

Quote:
> > > index  instead of 1 is 0 (same index that it has in UnitField!!!) ,
> anyone
> > > has any idea what would be wrong> ,shouldn't they be unique?

> > > here is my code

> > > #pragma once

> > > #include "stdafx.h"

> > > namespace NewDL

> > > {

> > >     private __value enum UnitField
> > >     {

> > >     enObjectID, enUnitName, enAnimalCount, enUnitType, enUnitSubType1,

> > >     enUnitSubType2, enUnitStatus

> > >     };

> > >     private __value enum CustomerField

> > >     {

> > >     enFirstName, enObjectID, enLastName, enAddress1, enAddress2,
enCity,
> > > enProvince, enCountry, enPostal_ZipCode, enPhone,

> > >     enCell, enFax,{*filter*}il

> > >     };

> > > }

> > > Thanks in advace

> > > Reza



Wed, 12 Jan 2005 16:31:53 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Enum as Array Index...

2. typedef enum as subset of another enum

3. enum - enum ?

4. enum - enum ?

5. array indexing by pointer and long index

6. indexed sequential, indexed, inverted, hash or direct file support

7. Union (not Enum) problem for interfaces (sorry!)

8. Enum problem for interfaces

9. Problems with enum

10. Problem with Character Processing and Enum

11. Problem with character processing and Enum.

12. enum & struct scope problems

 

 
Powered by phpBB® Forum Software