PageRenderTime 25ms CodeModel.GetById 21ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-24/SWIG/Examples/modula3/enum/example.cxx

#
C++ | 32 lines | 28 code | 3 blank | 1 comment | 21 complexity | 810384cc97edb4587bf3e4fefb85ac79 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1/* File : example.cxx */
 2
 3#include "example.h"
 4#include <stdio.h>
 5
 6void Foo::enum_test(speed s) {
 7  if (s == IMPULSE) {
 8    printf("IMPULSE speed\n");
 9  } else if (s == WARP) {
10    printf("WARP speed\n");
11  } else if (s == LUDICROUS) {
12    printf("LUDICROUS speed\n");
13  } else if (s == HYPER) {
14    printf("HYPER speed\n");
15  } else {
16    printf("Unknown speed\n");
17  }
18}
19
20void enum_test(color c, Foo::speed s) {
21  if (c == RED) {
22    printf("color = RED, ");
23  } else if (c == BLUE) {
24    printf("color = BLUE, ");
25  } else if (c == GREEN) {
26    printf("color = GREEN, ");
27  } else {
28    printf("color = Unknown color!, ");
29  }
30  Foo obj;
31  obj.enum_test(s);
32}