?
=?ISO-8859-1?Q?Ignaz_Kr=E4henmann?=
Hello
I'm back to C++ programming after many years and forgot quite a lot. Can
someone help me with the following enum issue:
enum type1 {OK = 0, NOK};
enum type2 {OK = 100, FAIL};
type1 oknok;
type2 okfail;
oknok = OK;
okfail = OK;
It seems to me that it is quite obvious what the compiler needs to do:
If the variable is of type1 it should use 0 for OK and for type2 OK
should be 100. Or, more general, the variable type defines the possible
values through the declaration.
gcc, however, issues an error saying "conflicting types for 'OK'". Why
should this not be possible?
Intrestingly, if I code the following:
oknok = FAIL;
gcc sais: "cannot convert 'type2' to 'type1' in assignment". So
obviously the compiler knows which value is possible for which variable.
What am I getting wrong? Thanks.
I'm back to C++ programming after many years and forgot quite a lot. Can
someone help me with the following enum issue:
enum type1 {OK = 0, NOK};
enum type2 {OK = 100, FAIL};
type1 oknok;
type2 okfail;
oknok = OK;
okfail = OK;
It seems to me that it is quite obvious what the compiler needs to do:
If the variable is of type1 it should use 0 for OK and for type2 OK
should be 100. Or, more general, the variable type defines the possible
values through the declaration.
gcc, however, issues an error saying "conflicting types for 'OK'". Why
should this not be possible?
Intrestingly, if I code the following:
oknok = FAIL;
gcc sais: "cannot convert 'type2' to 'type1' in assignment". So
obviously the compiler knows which value is possible for which variable.
What am I getting wrong? Thanks.