Last change
on this file since dd78dbc was
1725989,
checked in by Peter A. Buhr <pabuhr@…>, 3 months ago
|
add enumeration test programs for different programming languages
|
-
Property mode set to
100644
|
File size:
872 bytes
|
Rev | Line | |
---|
[1725989] | 1 | #include <iostream> |
---|
| 2 | using namespace std; |
---|
| 3 | void fred() { |
---|
| 4 | } |
---|
| 5 | |
---|
| 6 | int main() { |
---|
| 7 | enum class E { A, B, C }; |
---|
| 8 | enum W { K, J, L }; |
---|
| 9 | char www[L]; |
---|
| 10 | int i; |
---|
| 11 | // i = E::A; i = K; |
---|
| 12 | E e; |
---|
| 13 | // e = 42; |
---|
| 14 | enum class CCC : char { A = 'a', B, C }; |
---|
| 15 | CCC c; |
---|
| 16 | // char ch = E::A; |
---|
| 17 | // c = 'z'; |
---|
| 18 | enum class RGB : long { Red, Green, Blue }; |
---|
| 19 | enum class rgb : char { Red = 'r', Green = 'g', Blue = 'b' }; |
---|
| 20 | enum class srgb : signed char { Red = -1, Green = 0, Blue = 1 }; |
---|
| 21 | RGB colour1 = RGB::Red; |
---|
| 22 | rgb colour2 = rgb::Red; |
---|
| 23 | srgb colour3 = srgb::Red; |
---|
| 24 | // int s = E::A + E::A; |
---|
| 25 | if ( rgb::Red == rgb::Blue ) cout << "FRED" << endl; |
---|
| 26 | if ( rgb::Red == rgb::Green ) cout << "FRED0" << endl; |
---|
| 27 | if ( rgb::Red == rgb::Red ) cout << "FRED1" << endl; |
---|
| 28 | cout << (int)rgb::Red << endl; |
---|
| 29 | switch ( colour2 ) { |
---|
| 30 | case rgb::Red: ; |
---|
| 31 | case rgb::Green: ; |
---|
| 32 | case rgb::Blue: ; |
---|
| 33 | } |
---|
| 34 | for ( int i = rgb::Red; i < rgb::Blue; i += 1 ) {} |
---|
| 35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.