C Enum
Code:
In an effort not to hijack another thread i created this one for a little help understanding enum now according to what im told/read this code should generate an error when compiling because im assigning it something thats not enum'ed at least a warning. This is not so. Gcc gives no error or warning not even with -Wall so is this a leagal use of enum or should i be getting a warning ? |
Yes, that's legal. If you define something with an enum type, the compiler makes it an integer so you can have any value assigned to it, not just those in your enum statement.
|
then whats the point in using it ? why not just declare regular varibles.
|
The advantage of an enum is that it has scope, compared to a #define statement. You could just use regular variables, but that advantage to this is it automatically numbers them for you so you don't have to go through the process of doing that.
|
All times are GMT -5. The time now is 10:50 PM. |