Scrigroup - Documente si articole

Username / Parola inexistente      

Home Documente Upload Resurse Alte limbi doc  


AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows
WordXml

AspAutocadCDot netExcelFox proHtmlJava
LinuxMathcadPhotoshopPhpSqlVisual studioWindowsXml

Enums

c

+ Font mai mare | - Font mai mic



DOCUMENTE SIMILARE

Trimite pe Messenger
Enums
Initialization - Constant expressions
Keywords and identifiers
The alphabet of C
Pointers and Arrays: Pointers and Addresses
Simple arrays
Sequence points
Input and Output: Standard Input and Output
Complete Programs in C
Functions


Enums

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:

enum e_tagvar;

Just as with structures and unions, the e_tag 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:

a == 0
b == 1
c == 2
d == 20
e == 21
f == 22
g == 20
h == 21

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
#define b 1
/* and so on */

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;

The names a, b, and 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 ep without violating the type-compatibility requirements for pointers.






Politica de confidentialitate



DISTRIBUIE DOCUMENTUL

Comentarii


Vizualizari: 502
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2022 . All rights reserved

Distribuie URL

Adauga cod HTML in site