J
Jarmo Muukka
Hello all!
I have used C++ for many years and recently I have used C#. Now I am coding
in C++ and I have a problem now.
In C# you can do enums like this:
enum Lane
{
Left,
Right
}
enum Answer
{
Right,
Wrong
}
Lane lane = Lane.Right;
Answer answer = Answer.Right;
If you try to do similar in C++, it will not compile:
enum Lane
{
Left,
Right
};
enum Answer
{
Right, // <- compiler says Right is already defined
Wrong
};
Lane lane = Lane::Right; // <- compiler says 'Right' is not a member of
'Lane'
Answer answer = Answer::Right; // <- compiler says 'Right' is not a
member of 'Answer'
How would you fix these problems, if you would want to write it in C# way? I
would like to use logical names. It's not always possible to know what other
enums there are defined or will be defined.
JMu
I have used C++ for many years and recently I have used C#. Now I am coding
in C++ and I have a problem now.
In C# you can do enums like this:
enum Lane
{
Left,
Right
}
enum Answer
{
Right,
Wrong
}
Lane lane = Lane.Right;
Answer answer = Answer.Right;
If you try to do similar in C++, it will not compile:
enum Lane
{
Left,
Right
};
enum Answer
{
Right, // <- compiler says Right is already defined
Wrong
};
Lane lane = Lane::Right; // <- compiler says 'Right' is not a member of
'Lane'
Answer answer = Answer::Right; // <- compiler says 'Right' is not a
member of 'Answer'
How would you fix these problems, if you would want to write it in C# way? I
would like to use logical names. It's not always possible to know what other
enums there are defined or will be defined.
JMu