| Last change
 on this file since 5db913f was             eae8b37, checked in by JiadaL <j82liang@…>, 11 months ago | 
        
          | 
Move enum.hfa/enum.cfa to prelude
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1018 bytes | 
      
      
| Line |  | 
|---|
| 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 () { | 
|---|
| 14 | Colour fishy; | 
|---|
| 15 | fishy = Colour.Green; | 
|---|
| 16 | fishy; | 
|---|
| 17 | Colour c2 = fishy; | 
|---|
| 18 |  | 
|---|
| 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; | 
|---|
| 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 ); | 
|---|
| 31 |  | 
|---|
| 32 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.