Last change
on this file since 94aa202 was
eae8b37,
checked in by JiadaL <j82liang@…>, 2 weeks ago
|
Move enum.hfa/enum.cfa to prelude
|
-
Property mode set to
100644
|
File size:
1018 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 | |
---|
[eae8b37] | 19 | sout | "Enumeration Constant<Blue>:: value: " | value(Colour.Blue) | ", position: " | posn(Colour.Blue) | ", label: " | label(Colour.Blue) | ", default output: " | Colour.Blue; |
---|
| 20 | sout | "Runtime Value<fishy>:: value: " | value(fishy) | ", position: " | posn(fishy) | ", label: " | label(fishy) | ", default output: " | fishy; |
---|
| 21 | sout | "Runtime Value<C2>:: value: " | value(c2) | ", position: " | posn(c2) | ", label: " | label(c2) | ", default output: " | 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.