原来default还可以写在前面啊,我还以为会编译错误呢!汇编是这样嘀:
代码:
switch(temp)
00411509 mov eax,dword ptr [temp]
0041150C mov dword ptr [ebp-0DCh],eax
00411512 cmp dword ptr [ebp-0DCh],1
00411519 je wmain+0AFh (41154Fh)
0041151B cmp dword ptr [ebp-0DCh],2
00411522 je wmain+0DAh (41157Ah)
{
default:
cout<<"the number is not 1 or 2"<<endl;
00411524 mov esi,esp
00411526 mov eax,dword ptr [__imp_std::endl (41A308h)]
0041152B push eax
0041152C push offset string "the number is not 1 or 2" (417724h)
00411531 mov ecx,dword ptr [__imp_std::cout (41A304h)]
00411537 push ecx
00411538 call std::operator<<<std::char_traits<char> > (41115Eh)
0041153D add esp,8
00411540 mov ecx,eax
00411542 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (41A300h)]
00411548 cmp esi,esp
0041154A call @ILT+415(__RTC_CheckEsp) (4111A4h)
case 1:
cout<<"the number is 1 "<<endl;
0041154F mov esi,esp
00411551 mov eax,dword ptr [__imp_std::endl (41A308h)]
00411556 push eax
00411557 push offset string "the number is 1 " (417710h)
0041155C mov ecx,dword ptr [__imp_std::cout (41A304h)]
00411562 push ecx
00411563 call std::operator<<<std::char_traits<char> > (41115Eh)
00411568 add esp,8
0041156B mov ecx,eax
0041156D call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (41A300h)]
00411573 cmp esi,esp
00411575 call @ILT+415(__RTC_CheckEsp) (4111A4h)
case 2:
cout<<"the number is 2 "<<endl;
0041157A mov esi,esp
0041157C mov eax,dword ptr [__imp_std::endl (41A308h)]