Enumerations: Difference between revisions
Content added Content deleted
(New page: {{task}} <div class="messagebox"> Create an enumeration of types with and without values. </div> ==BASIC== Category:BASIC '''Interpeter:''' QuickBasic 4.5, PB 7.1 REM Impo...) |
|||
Line 9: | Line 9: | ||
'''Interpeter:''' [[QuickBasic]] 4.5, PB 7.1 |
'''Interpeter:''' [[QuickBasic]] 4.5, PB 7.1 |
||
REM Impossible. Can only faked with arrays of strings. |
REM Impossible. Can only be faked with arrays of strings. |
||
OPTION BASE 1 |
|||
DIM SHARED fruitsName$(1 to 3); |
|||
DIM SHARED fruitsVal%( 1 to 3); |
|||
fruitsName$[1] = "apple"; |
|||
fruitsName$[2] = "banana"; |
|||
fruitsName$[3] = "cherry"; |
|||
fruitsVal%[1] = 1; |
|||
fruitsVal%[2] = 2; |
|||
fruitsVal%[3] = 3; |
|||
==[[C]]== |
==[[C]]== |
Revision as of 03:18, 23 February 2007
Enumerations
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
BASIC
Interpeter: QuickBasic 4.5, PB 7.1
REM Impossible. Can only be faked with arrays of strings. OPTION BASE 1 DIM SHARED fruitsName$(1 to 3); DIM SHARED fruitsVal%( 1 to 3);
fruitsName$[1] = "apple"; fruitsName$[2] = "banana"; fruitsName$[3] = "cherry";
fruitsVal%[1] = 1; fruitsVal%[2] = 2; fruitsVal%[3] = 3;
C
Compiler: GCC, MSVC, BCC, Watcom
Libraries: Standard
enum fruits { apple, banana, cherry };
enum fruits { apple = 0, banana = 1, cherry = 2 };
C++
Compiler: GCC, Visual C++, BCC, Watcom
enum fruits { apple, banana, cherry };
enum fruits { apple = 0, banana = 1, cherry = 2 };
C#
enum fruits { apple, banana, cherry }
enum fruits { apple = 0, banana = 1, cherry = 2 }
enum fruits : int { apple = 0, banana = 1, cherry = 2 }
D
Forth
Fortran
Java
Java 1.5 only
enum fruits { apple, banana, cherry }; enum fruits { apple = 0, banana = 1, cherry = 2 };
JavaScript
enum fruits { apple, banana, cherry }; enum fruits { apple = 0, banana = 1, cherry = 2 };
Perl
Interpeter: Perl
enum fruits { apple, banana, cherry }; enum fruits { apple = 0, banana = 1, cherry = 2 };
PHP
enum fruits { apple, banana, cherry }; enum fruits { apple = 0, banana = 1, cherry = 2 };
Python
Interpeter: Python 2.3, 2.4, 2.5