![]() To get the integer value from an item, you must explicitly convert. ![]() Trouble is the enum is still implemented like 'int', so you can do all sorts of nasty things as wilfredmedlin points out and force the enum to have a value which not been defined. In strict C89 or C99 mode, the compiler allows only enumeration constants with values that will fit in int or unsigned int (32 bits). By default, the first item of an enum has the value 0. Line 11: We use type casting to convert the Result.Pass enum into an int. So the value of Fail is 0 and the value of Pass is 1. So they gave up and just enforced stronger typing and don't allow integer operations. The default underlying data type for an enum is int. ![]() I believe the argument was that iterating over an enum would require it to be some form of set and would need a data structure more than just a simple 'integer' to implement - but that would make it incompatible with 'old' enum. You can explicitly cast to int and back again: (which will be frowned upon) enum EDIT_MODE A variable of an enum type is an integer variable that the. I know that an enum is an integer and you can do math operations on it. An enum, short for enumeration, is a list of symbolic tags that have constant integer value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |