-
name conflicts in enum
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
-
Unless they are in separate header files that are unrelated, or you are using C++, you can't.
In C++, you can use foo::NAME and goo::NAME [I think!]
It's a bad idea to use the same enum name for different values. Renaming at least one so that it's got unique names would be much better.
--
Mats
-
Hence why you usually name the members of the enum prefixed with the name of the enum, for example.
Code:
enum foo {
FOO_NAME = 100;
};
enum goo {
GOO_NAME = 200;
};
Or even, G_NAME and F_NAME.