Synopsis: | Mixing of different enum types is not allowed. |
Language: | C |
Severity Level: | 4 |
Category: | Declarations |
Description: |
Justification This is considered bad practice and can also result in unexpected behavior. Example enum Animal { CAT, DOG, PIG, HORSE }; enum Color { BLACK, RED, YELLOW }; Animal eAnimal = RED; /* WRONG */ Note The C++ language already contains enumerated types as distinct types. Consequently, trying to assign enumerators from one enum type to another enum type will cause a C++ compiler error. |