C++枚举类型重定义

#include <iostream>
#include <string>
#include "Helper.h"
using namespace  std;
using namespace PerfomanceEstimateService;
using namespace std;
enum enA
{
 A_1 = 1,
 A_2 = 2,
};
enum enB
{
 A_1_ = 1,   //如果这样定义A_1 = 1, 则错误提示 A_1;重定义;以前的定义是"枚举数"
 A_2_ = 2,   //如果这样定义A_2 = 1,则错误提示 A_1;重定义;以前的定义是"枚举数"
};
void main()
{
 enA ena = enA::A_1;
 enB enb = enB::A_1_;


 int na = (int)ena;
 int nb = (int)enb;

 cout << na << endl;    //输出1
 cout << nb << endl;   //输出1
 

 int wait;
 cin >> wait;
}


 

posted @ 2013-06-20 20:37  Predator  阅读(3411)  评论(0编辑  收藏  举报