/trunk/Examples/go/enum/example.cxx

# · C++ · 37 lines · 33 code · 3 blank · 1 comment · 27 complexity · c4782af34e60c685f0c6f5d43cb5dcfd MD5 · raw file

  1. /* File : example.cxx */
  2. #include "example.h"
  3. #include <stdio.h>
  4. void Foo::enum_test(speed s) {
  5. if (s == IMPULSE) {
  6. printf("IMPULSE speed\n");
  7. } else if (s == WARP) {
  8. printf("WARP speed\n");
  9. } else if (s == LUDICROUS) {
  10. printf("LUDICROUS speed\n");
  11. } else {
  12. printf("Unknown speed\n");
  13. }
  14. }
  15. void enum_test(color c, Foo::speed s) {
  16. if (c == RED) {
  17. printf("color = RED, ");
  18. } else if (c == BLUE) {
  19. printf("color = BLUE, ");
  20. } else if (c == GREEN) {
  21. printf("color = GREEN, ");
  22. } else {
  23. printf("color = Unknown color!, ");
  24. }
  25. if (s == Foo::IMPULSE) {
  26. printf("speed = IMPULSE speed\n");
  27. } else if (s == Foo::WARP) {
  28. printf("speed = WARP speed\n");
  29. } else if (s == Foo::LUDICROUS) {
  30. printf("speed = LUDICROUS speed\n");
  31. } else {
  32. printf("speed = Unknown speed!\n");
  33. }
  34. }