|Access||Adobe photoshop||Algoritmi||Autocad||Baze de date||C||C sharp|
|Calculatoare||Corel draw||Dot net||Excel||Fox pro||Frontpage||Hardware|
|Php||Power point||Retele calculatoare||Sql||Tutorials||Webdesign||Windows|
|Asp||Autocad||C||Dot net||Excel||Fox pro||Html||Java|
These fall into the category of ‘half baked’. They aren't proper enumerated
types, as in Pascal, and only really serve to help you reduce the number of
#define statements in your program. They
look like this:
Just as with structures and unions, the
is the tag, and
var is the
definition of a variable.
The names declared inside the enumeration are constants with
int type. Their values are these:
so you can see that, in the absence of anything to the contrary, the values assigned start at zero and increase. A specific value can be given if you want, when the increase will continue one at a time afterwards; the specific value must be an integral constant (see later) that is representable in an int. It is possible for more than one of the names to have the same value.
The only use for these things is to give a better-scoped version of this:#define a 0
It's better scoped because the declaration of enumerations follows the
standard scope rules for C, whereas
#define statements have file scope.
Not that you are likely to care, but the Standard states that enumeration types are of a type that is compatible with an implementation-defined one of the integral types. So what? For interest's sake here is an illustration:enum eee_var, *ep;
c all behave as if they were
int constants when you use them;
e_var has type
enum ee and
ep is a pointer to enum
ee. The compatibility requirement means
that (amongst other implications) there will be an integral type whose address
can be assigned to
without violating the type-compatibility requirements for pointers.
Politica de confidentialitate|
Adauga cod HTML in site