name conflicts in enum

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
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
 
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 said:
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 said:
Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
Hi Cholo,


Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.


regards,
George

Cholo Lennon said:
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 said:
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 said:
Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
Thanks Cholo,


It works! Cool!


regards,
George

Cholo Lennon said:
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 said:
Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
- microsoft.public.vc.language
- microsoft.public.vc.atl (for your question about COM)

Regards

--
Cholo Lennon
Bs.As.
ARG


George said:
Hi Cholo,


Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.


regards,
George

Cholo Lennon said:
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 said:
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


Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
Thanks Cholo!


regards,
George

Cholo Lennon said:
- microsoft.public.vc.language
- microsoft.public.vc.atl (for your question about COM)

Regards

--
Cholo Lennon
Bs.As.
ARG


George said:
Hi Cholo,


Could you recommend me a better newsgroup which is more suitable for my
question please? Thanks.


regards,
George

Cholo Lennon said:
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


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


Hello everyone,


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

Code:
enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

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


thanks in advance,
George
 
Back
Top