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

  

相关文章:

  • 2021-04-06
  • 2021-06-12
  • 2021-09-29
  • 2021-06-25
  • 2022-01-05
  • 2021-05-18
猜你喜欢
  • 2021-05-17
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-01-10
相关资源
相似解决方案