From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/SYNTAX/enum.html | 97 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 reference/C/SYNTAX/enum.html (limited to 'reference/C/SYNTAX/enum.html') diff --git a/reference/C/SYNTAX/enum.html b/reference/C/SYNTAX/enum.html new file mode 100644 index 0000000..8f6b393 --- /dev/null +++ b/reference/C/SYNTAX/enum.html @@ -0,0 +1,97 @@ +The enum statement + + + + +
+
+

The enum statement

+
+
+

+ENUM is closely related to the #define +preprocessor.

+It allows you to define a list of aliases which represent integer numbers. For +example if you find yourself coding something like: +

+        #define MON 1 
+        #define TUE 2 
+        #define WED 3 
+
+You could use enum as below. +
+        enum week { Mon=1, Tue, Wed, Thu, Fri Sat, Sun} days;
+  or
+        enum escapes { BELL   = '\a', BACKSPACE = '\b', HTAB = '\t',
+                       RETURN = '\r', NEWLINE   = '\n', VTAB = '\v' };
+                       
+  or     
+        enum boolean { FALSE = 0, TRUE };
+ 
+
+ +An advantage of enum over #define is that it has +scope +This means that the variable (just like any other) is only visable +within the block it was declared within. +

+


+

Notes:

+ + + +
+

See Also:

+ + C++ Enhancements to enum.

+#define preprocessor.

+ +


+

Examples:

+ + +enum example 1.

+ +enum example 2.

+ + +enum coding error.

+ + +Another enum coding error.

+ + +enum and #define coding error.

+ +

+ +


+

+

+ + + + +
+ Top + + Master Index + + Keywords + + Functions +
+
+

+


+
Martin Leslie +

+ + -- cgit v1.2.3-54-g00ecf