Enumerated types... what's the point?
Michael T. Sullivan
sullivan at aqdata.uucp
Sat Mar 24 09:45:09 AEST 1990
I missed the beginning of this discussion so forgive me if this has
been gone over but has anybody mentioned the assignment of clashing
enum variables? For instance:
typedef enum { red, green, brown, yellow } colors;
typedef enum { huey, dewey, louie } ducks;
main()
{
colors a;
ducks b;
a = red;
b = huey;
a = 1
a = b;
}
produces a compiler error at "a = 1" and "a = b". This makes sure people
can't make an end run around the values a given variable should have,
which they could easily do if #define's were used for the values.
--
Michael Sullivan uunet!jarthur!aqdata!sullivan
aQdata, Inc. sullivan at aqdata.uucp
San Dimas, CA +1 714 599 9992
More information about the Comp.lang.c
mailing list