int main() { _asm{ mov edi,edi mov edi,edi } enum Color{Red=12,Green,Yellow}; _asm{ mov edi,edi mov edi,edi } Color c=Red; //The only valid values that you can assign to an enumeration variable without a type //cast are the enumerator values used in defining the type. //c=13; c=Color(54); int count; count=Red+4; return 0; };
然后查看assembly,
5: _asm{
6: mov edi,edi
0041139E 8B FF mov edi,edi
7: mov edi,edi
004113A0 8B FF mov edi,edi
8: }
9: enum Color{Red=12,Green,Yellow};
10: _asm{
11: mov edi,edi
004113A2 8B FF mov edi,edi
12: mov edi,edi
004113A4 8B FF mov edi,edi
13: }
可以说明:
声明enum don't allocate any memory.