Implementation of enum data type in ANSI C and C++
An enumerated data type is a user-defined data type through which names can be attached to numbers.
The declaration is almost same in Ansi C and C++. Consider following example-
 enum shape(circle, rectangle, square, riangle);
 enum color(red, green, yellow, white);
First difference
In C++ the tag names shape and color becomes new type name. By using these tag name we can declare new variables. Examples-
shape hyperbola;Â Â Â //hyperbola is of type shape
color foreground;Â Â Â //foreground is of type color
But In Ansi C it would be like this..
enum shape hyperbola;Â Â Â //hyperbola is of type shape
enum color foreground;Â Â Â //foreground is of type color
Second difference
Ansi C defines the type of enum to be ints, But in C++, enum datatype retain its own separate type. Because of this C++ does not permit an int value to be assigned to the enum variables. This can be done by type conversion.
For example-
color foreground =red;   // allowd
color foreground=3;       //not allowed, the integer needs to be converted in to color type.