Is the following enumeration declaration valid? Explain why or why not.
Is the following enumeration declaration valid? Explain why or why not.
Model answer
No, it is illegal. An enum member with no explicit value takes the previous member's value plus 1. So c becomes 8, and d is also explicitly assigned 8. Every member of an enum must have a unique value, so this is a compile error. Either of these changes fixes it: