您的位置:首页 > 其它

enum枚举类型的定义

2015-04-23 20:56 218 查看
enum枚举类型的定义方式与某种用法

#include <iostream>
using namespace std;

int main()
{
enum TOT{ zero, one, two, three, four, five };//0,1,2,3,4,5
TOT to1;
to1 = five;
switch (to1)
{
case 0:cout << "zero\n"; break;
case 1:cout << "one\n"; break;
case 2:cout << "two\n"; break;
case 3:cout << "three\n"; break;
case 4:cout << "four\n"; break;
case 5:cout << "five\n"; break;
default:cout << "数值错误\n"; break;
}
system("pause");
return 0;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: