Sunday, July 22, 2007

Enum: keyword, Code Listing

Enum:
• enum is a distinct type consisting of a set of named constants called the enumerator list
• Every enumeration type has an underlying type, which can be any integral type EXCEPT char
• Default underlying type of the enumeration is int
• enums start with 0 advancing by 1, can be forced to start with 1 or custom value
• Default : enum days{Sat, Sun, Mon, Tue, Wed, Thu, Fri};
• Cusotm setting: enum days{Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
• Default value of an enum E is the value produced by the expression (E)0
• Typecasting needed for assigment: int x = (int)days.Sun;

No comments: