An enum () - , , . . - .
enum . , enum, .
, . , . - , , ( ).
It is also convenient to add a new symbolic name later and allow the values to reorder themselves. However enum, the are Cnot strictly typified and compatible with whole characters. This way you can assign any value to a type variable enum.
enum fruits {APPLE, PEARS, BANANA};
enum fruits {APPLE, MANGO, PEARS, BANANA};
enum color {APPLE, PEACH};
enum color my_color = MANGO;
enum fruits my_fruit = 7;
However, it enumis C++strongly typed.
enum class Traffic_light {red, yellow, green};
enum class Warning {green, yellow, orange, red};
Warning w = 1;
Traffic_light t = Warning::red;
source
share