| 60 | }; |
| 61 | |
| 62 | int main() |
| 63 | { |
| 64 | // 定义新的枚举变量 |
| 65 | Color::Type c = Color::RED; |
| 66 | cout << c << endl; // 15 |
| 67 | /** |
| 68 | * 上述的另一种方法: |
| 69 | * using namespace Color; // 定义新的枚举变量 |
| 70 | * Type c = RED; |
| 71 | */ |
| 72 | Color1 c1; |
| 73 | cout << c1.RED << endl; // 102 |
| 74 | |
| 75 | Color1::Type c11 = Color1::BLUE; |
| 76 | cout << c11 << endl; // 104 |
| 77 | |
| 78 | Color2 c2 = Color2::RED; |
| 79 | // cout << c2 << endl; // error |
| 80 | cout << static_cast<int>(c2) << endl; // 2 |
| 81 | |
| 82 | char c3 = static_cast<char>(Color3::RED); |
| 83 | cout << c3 << endl; // r |
| 84 | return 0; |
| 85 | } |
nothing calls this directly
no outgoing calls
no test coverage detected