User
defined data type
enum
keyword
enum
week {mon, tues, wed, thur, fri, sat, sun};
enum
week day = wed;
//Here
day is the variable of type week
//Value
of day is = 2;
//value
of mon = 0, tue = 1, and so on
We
can initalize two enum names to same value.
If
we don not explicitly initialize vlues to names, compiler will assign default
values from 0.
ex:
enum value { day1 = 19, day2, day3=91, day4}
Here
compiler assign value of day2 = 20 and day4 = 92
enum
exam{test, sample};
enum
lab{sample, collect};
sample
in two enums in same scope not allowed
No comments:
Post a Comment