为什么这段代码不能编译,我该怎么做才能让它编译?
#include <iostream>
using namespace std;
enum class myEnum : unsigned int
{
bar = 3
};
int main() {
// your code goes here
unsigned int v = 2;
switch(v)
{
case 2:
break;
case myEnum::bar:
break;
}
return 0;
}
想法:
prog.cpp: In function 'int main()':
prog.cpp:18:16: error: could not convert 'bar' from 'myEnum' to 'unsigned int'
case myEnum::bar:
无法在 GCC 和 Clang 中构建,适用于 MSVC 2013。