non-integral enums?
Derek Parnell
derek at psych.ward
Fri Feb 24 19:03:07 PST 2006
On Sat, 25 Feb 2006 13:12:10 +1100, Wang Zhen <nehzgnaw at gmail.com> wrote:
[snip]
> How different is enum from constants then?
I agree. I thought enum were invented as a shorthand way of doing ...
const int red = 1,
blue = 2,
green = 3;
Instead we can do 'enum colors { red, blue, green }'
To saving the coder having to recalculate the 'enumerated' names when some
were added or deleted.
const int red = 1,
yellow = 2,
blue = 3,
green = 4;
Instead we can do 'enum colors { red, yellow, blue, green }'
Otherwise they are just constants of varying values.
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list