I know that if I have defined an enum weekday like this:
Enum weekday {mon, tue, wed, thu, fa,}; Then, the mon will be internally equal to 0, by default, and 1, from WED to WED 2 ...
But if I do it like this I define: / P>
enum weekdays {mon, teie = 0, wade, thu, fa,}; Then both the MON and TUE will get the value of 0. How different will the system be internal and TUE? I mean, if I declare something like this:
today's day = 0; So today is mon or TUE ? Or, both philosopher-speaking,
C enums are "in fact" integers - not just because they are implemented in such a way , But because standard defines enum types have integer values, then today's value is "actually" 0. Whatever has happened is that you have two variations for value 0 Names have been created. I think the answer is "Today is MON or TEE" "Yes"; -)
The language can not stop you because sometimes it is useful for many names of the same value for the value. For example:
enum compression_method {COMP_NONE = 0, COMP_LOW = 1, COMP_HIGH = 2, COMP_BEST = 2, COMP_FASTEST = 0,};
Comments
Post a Comment