N
Neil Zanella
Hello,
I have seen code that does the following:
enum Letter { X, Y, Z, numLetters };
Is this considered good or bad code? On one hand, the code seems more
maintainable because no matter whether letters are added or removed
the value of numLetters will be correct (as long as no letter is
given a number with the equal sign which makes this untrue).
On the other hand, this forces the need for needless default
cases in switch statements since the compiler will complain
if in a switch numLetters above is not taken care of.
So, is this good or bad?
Opinions welcome,
Regards,
Neil
I have seen code that does the following:
enum Letter { X, Y, Z, numLetters };
Is this considered good or bad code? On one hand, the code seems more
maintainable because no matter whether letters are added or removed
the value of numLetters will be correct (as long as no letter is
given a number with the equal sign which makes this untrue).
On the other hand, this forces the need for needless default
cases in switch statements since the compiler will complain
if in a switch numLetters above is not taken care of.
So, is this good or bad?
Opinions welcome,
Regards,
Neil