Objective-C / C giving enums default values

Posted by bandejapaisa on Stack Overflow See other posts from Stack Overflow or by bandejapaisa
Published on 2010-05-14T07:54:13Z Indexed on 2010/05/14 8:14 UTC
Read the original article Hit count: 238

Filed under:
|
|
|

I read somewhere about giving enums default values like so:

typedef enum  {
MarketNavigationTypeNone = 0,
MarketNavigationTypeHeirachy = 1,
MarketNavigationTypeMarket = 2
} MarketNavigationLevelType;

.. but i can't remember the value of doing this. If i don't give them default values - and then someone later on reorders the enum - what are the risks?

If i always use the enum name and don't even refer to them by their integer value, is there any risks?

The only possible problem i can think of is if i'm initialising an enum from an int value from a DB - and the enum is reordered - then the app would break.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about c