J
James Brown
I have the following enum declared:
enum TOKEN { TOK_ID = 1000, TOK_NUMBER, TOK_STRING };
(it goes on and on like that)
This is what I would like to do:
TOKEN t1 = TOK_ID; // ok
TOKEN t2 = 5; // compile error (cannot convert from
const int to 'enum TOKEN')
TOKEN t3 = (TOKEN)5; // compiles but I think it's illegal???
could someone clarify if the 3rd example is ok or not, and what type
of problem I might expect if it isn't ok?
What I am trying to do is represent ASCII values 0-127 as TOKENs (this is
why I
started the TOKEN enum off at '1000' so I had plenty of space at the
start....and I don't
really want to type out 127 values into my enum declaration....can anybody
suggest
an alternate solution?
thanks,
James
enum TOKEN { TOK_ID = 1000, TOK_NUMBER, TOK_STRING };
(it goes on and on like that)
This is what I would like to do:
TOKEN t1 = TOK_ID; // ok
TOKEN t2 = 5; // compile error (cannot convert from
const int to 'enum TOKEN')
TOKEN t3 = (TOKEN)5; // compiles but I think it's illegal???
could someone clarify if the 3rd example is ok or not, and what type
of problem I might expect if it isn't ok?
What I am trying to do is represent ASCII values 0-127 as TOKENs (this is
why I
started the TOKEN enum off at '1000' so I had plenty of space at the
start....and I don't
really want to type out 127 values into my enum declaration....can anybody
suggest
an alternate solution?
thanks,
James