Guest User

Untitled

a guest
Jun 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. enum Color { Red,Green,Blue };
  2. enum Size { Big,Little };
  3.  
  4. void f( Color c ) {
  5. }
  6.  
  7. void f( Size s ) {
  8. }
  9.  
  10. int main() {
  11. f( Red );
  12. f( Big );
  13. }
  14.  
  15. int f(int fg, int bg)
  16.  
  17. int f(COLOR fg, COLOR bg)
  18.  
  19. template <int N>
  20. struct foo
  21. {
  22. enum { Value = foo<N-1>::Value + N };
  23. };
  24.  
  25. template <>
  26. struct foo<0>
  27. {
  28. enum { Value = 0; }
  29. };
  30.  
  31. template <int N>
  32. struct foo
  33. {
  34. static const int Value = foo<N-1>::Value + N;
  35. };
  36.  
  37. template <>
  38. struct foo<0>
  39. {
  40. static const int Value = 0;
  41. };
  42.  
  43. #include <iostream>
  44. using namespace std;
  45.  
  46. class Bunch {
  47. enum { size = 1000 };
  48. int i[size];
  49. };
  50.  
  51. int main() {
  52. cout << "sizeof(Bunch) = " << sizeof(Bunch)
  53. << ", sizeof(i[1000]) = "
  54. << sizeof(int[1000]) << endl;
  55. }
  56.  
  57. enum {NONE, START, HEY, HO, LAST};
  58.  
  59. for (int i = NONE; i < LAST; i++)
  60. {
  61. // Do stuff...
  62. }
  63.  
  64. enum {NONE, START, HEY, WEE, HO, LAST};
  65.  
  66. class Foo {
  67. static const int MAX_LEN = 80;
  68. ...
  69. };
  70.  
  71. class Foo {
  72. enum {
  73. MAX_LEN = 80
  74. };
  75. ...
  76. };
  77.  
  78. enum my_new_fangled_type {
  79. baz = 0,
  80. meh = 1
  81. };
  82.  
  83. void foo (my_new_fangled_type bar) // bar can be a value listed in the enum
  84. {
  85. ...
  86. }
  87.  
  88. int const baz = 0;
  89. int const meh = 1;
  90.  
  91. void foo (int bar) // what are valid values for bar?
  92. {
  93. ...
  94. }
  95.  
  96. class C
  97. {
  98. const int ARealConstant = 10;
  99. };
  100.  
  101. class C
  102. {
  103. enum { ARealConstant = 10 };
  104. };
  105.  
  106. class DirectorySearcher
  107. {
  108. enum options
  109. {
  110. showFiles = 0x01,
  111. showDirectories = 0x02,
  112. showLinks = 0x04,
  113. };
  114. };
  115.  
  116. class Integer
  117. {
  118. enum { treatAsNumeric = true };
  119. enum { treatAsIntegral = true };
  120. enum { treatAsString = false };
  121. };
  122.  
  123. enum { Val1, Val2, Val3 };
  124.  
  125. const int Val1=0, Val2=1, Val3=2;
Add Comment
Please, Sign In to add comment