Last change
on this file since 1571e4d was
5eb3f65,
checked in by Peter A. Buhr <pabuhr@…>, 5 months ago
|
change enumeration function names labelE, valueE, posE to label, value, posn
|
-
Property mode set to
100644
|
File size:
1010 bytes
|
Rev | Line | |
---|
[c17dc80] | 1 | #include <fstream.hfa> |
---|
| 2 | #include <stdlib.hfa> |
---|
| 3 | #include <stdio.h> |
---|
| 4 | |
---|
| 5 | enum(char *) Colour { |
---|
| 6 | Red = "red", Green = "green", Blue = "blue" |
---|
| 7 | }; |
---|
| 8 | |
---|
| 9 | // enum( signed char ) srgb { Red = -1, Green = 0, Blue = 1 }; |
---|
| 10 | |
---|
| 11 | enum Plain { A, B, C = 10 }; |
---|
| 12 | |
---|
| 13 | int main () { |
---|
[eb7586e] | 14 | Colour fishy; |
---|
| 15 | fishy = Colour.Green; |
---|
| 16 | fishy; |
---|
[c17dc80] | 17 | Colour c2 = fishy; |
---|
[eb7586e] | 18 | |
---|
[5eb3f65] | 19 | sout | "Compile Time: blue value: " | value(Colour.Blue) | ", position: " | posn(Colour.Blue) | ", label: " | label(Colour.Blue) | ", default return value: " | Colour.Blue; |
---|
| 20 | sout | "Runtime: fishy value: " | value(fishy) | ", position: " | posn(fishy) | ", label: " | label(fishy) | ", default return value: " | fishy; |
---|
| 21 | sout | "Runtime: C2 value: " | value(c2) | ", position: " | posn(c2) | ", label: " | label(c2) | ", default return value: " | c2; |
---|
[c17dc80] | 22 | Colour.Red; |
---|
| 23 | char * ao = Colour.Red; |
---|
| 24 | char * ko = fishy; |
---|
| 25 | printf( "ao is %s\n", ao ); |
---|
| 26 | printf( "ko is %s\n", ko ); |
---|
| 27 | |
---|
| 28 | printf( "%d, %d, %d, \n", A, B, C ); |
---|
| 29 | Plain a = B; |
---|
| 30 | printf( "%d \n", a ); |
---|
[eb7586e] | 31 | |
---|
[5eb3f65] | 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.