Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Enum

Enum

Ratings: (0)|Views: 1 |Likes:
Published by Rakesh Patel

More info:

Published by: Rakesh Patel on Aug 14, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

10/31/2014

pdf

text

original

 
C Enumeration Declarations
Visual Studio 2005
 
Other Versions 147 out of 234 rated this helpful - Rate this topic  An enumeration consists of a set of named integer constants. An enumerationtype declaration gives the name of the (optional) enumeration tag and definesthe set of named integer identifiers (called the "enumeration set," "enumeratorconstants," "enumerators," or "members"). A variable with enumeration typestores one of the values of the enumeration set defined by that type.Variables of 
enum
type can be used in indexing expressions and as operands of all arithmetic and relational operators. Enumerations provide an alternative tothe
#define
preprocessor directive with the advantages that the values can begenerated for you and obey normal scoping rules.In ANSI C, the expressions that define the value of an enumerator constantalways have
int
type; thus, the storage associated with an enumeration variable isthe storage required for a single
int
value. An enumeration constant or a value of enumerated type can be used anywhere the C language permits an integerexpression.
enum-specifier 
:
enum
identifier 
opt
{
enumerator-list 
}
 
enum
identifier 
 The optional
identifier 
names the enumeration type defined by
enumerator-list 
.This identifier is often called the "tag" of the enumeration specified by the list. Atype specifier of the form
enum identifier { enumerator-list }
 
declares
identifier 
to be the tag of the enumeration specified by the
enumerator-list 
nonterminal. The
enumerator-list 
defines the "enumerator content."The
enumerator-list 
is described in detail below.If the declaration of a tag is visible, subsequent declarations that use the tag butomit
enumerator-list 
specify the previously declared enumerated type. The tagmust refer to a defined enumeration type, and that enumeration type must be incurrent scope. Since the enumeration type is defined elsewhere, the
enumerator-list 
does not appear in this declaration. Declarations of types derived fromenumerations and
typedef 
declarations for enumeration types can use theenumeration tag before the enumeration type is defined.
enumerator-list 
:
enumerator 
 
enumerator-list 
,
enumerator 
 
enumerator 
:
enumeration-constant 
 
enumeration-constant 
=
constant-expression
 
enumeration-constant 
:
identifier 
 Each
enumeration-constant 
in an
enumeration-list 
names a value of theenumeration set. By default, the first
enumeration-constant 
is associated with thevalue 0. The next
enumeration-constant 
in the list is associated with the value of (
constant-expression
+ 1 ), unless you explicitly associate it with another value.The name of an
enumeration-constant 
is equivalent to its value.You can use
enumeration-constant = constant-expression
to override the defaultsequence of values. Thus, if 
enumeration-constant = constant-expression
appearsin the
enumerator-list 
, the
enumeration-constant 
is associated with the valuegiven by
constant-expression
. The
constant-expression
must have
int
type and canbe negative.The following rules apply to the members of an enumeration set:

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->