enum枚举类型的定义

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;
}

  

posted on 2015-04-23 20:56  小咒  阅读(923)  评论(0编辑  收藏  举报

导航