|
From: Jason H. <jas...@bt...> - 2002-04-18 01:19:44
|
I agree, but in addition to that it can be useful for flags i.e.
enum state {calm =3D 0, upset =3D 1, crying =3D 2, nervous =3D 4, =
psychotic =3D 8};
So you could say I am feeling:
state myself =3D psychotic | crying;
Which should evaluate to (int) 10.
Jason.
PS: probably not the best example in the world, but humour me.
----- Original Message -----=20
From: Bob Wilson=20
To: Dev-C++ User Mailing List=20
Sent: Wednesday, April 17, 2002 7:29 PM
Subject: Fw: [Dev-C++] enum
The default is 0, and then each consequtive one is +1 the previous =
one. You can change the value of an enum by initialising it to something =
else, i.e.
enum farmyard {cow, sheep, pig, chicken, fruitbat =3D 1000, =
elephant, pigmi}
so cow =3D 0, sheep =3D 2, etc.. and then fruitbat =3D 1000, =
elephant =3D 1001, and so on.
Absolutely correct, but when you assign a value to an enumerated =
element, it practically destroys or greatly limits the ability to use =
the enumerated elements in a for loop or switch statement.=20
Regards,
Bob Wilson
|