N
Noah Roberts
I am having an interesting compilation error that makes me wonder if
enums can conflict with each other.
For example:
class A
{
enum X { TEST, TEST2 };
public:
....
};
class B
{
enum Y { TEST2 };
public:
....
};
My interpretation of that would be that there is a type A::X which can
contain the values A::TEST or A::TEST2 and type B::Y that can contain
B::TEST2. However, my compiler is complaining about stuff related to
the line that would be "enum Y..."
errors include:
parse error before numeric constant.
missing ';' before right brace.
parse error before 'public'
....
various others probably caused by the above...
If I change B's TEST2 to TEST2t it works. It was my understanding that
the enums would not conflict because they have totally different scope
(at least in C++). Do I need to only use const ints then?
enums can conflict with each other.
For example:
class A
{
enum X { TEST, TEST2 };
public:
....
};
class B
{
enum Y { TEST2 };
public:
....
};
My interpretation of that would be that there is a type A::X which can
contain the values A::TEST or A::TEST2 and type B::Y that can contain
B::TEST2. However, my compiler is complaining about stuff related to
the line that would be "enum Y..."
errors include:
parse error before numeric constant.
missing ';' before right brace.
parse error before 'public'
....
various others probably caused by the above...
If I change B's TEST2 to TEST2t it works. It was my understanding that
the enums would not conflict because they have totally different scope
(at least in C++). Do I need to only use const ints then?