c++ enum类型

来源:互联网 发布:太阳社玻尿酸原液 知乎 编辑:程序博客网 时间:2024/05/21 19:42
// easyTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <string>using namespace std;enum some_big_cities {Guangzhou ,//相当于键 ,而 0相当于值Shenzhen ,Hongkong ,Shanghai ,Beijing ,Chongqi };int _tmain(int argc, _TCHAR* argv[]){some_big_cities wh;//wh相当于iwh = Guangzhou;//给 i赋值,只不过这个值范围有限定cout << "the value is: " << wh << endl;//只能输出值getchar();return 0;}输出结果
the value is: 0
枚举常量:
enum{ emCurrHPMaxMember = 64};cout << emCurrHPMaxMember << endl;
可以直接输出。
原创粉丝点击