16,471
社区成员
发帖
与我相关
我的任务
分享
switch (uMsg)
{ case WM_PAINT:
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps); //有错:不能编译 error C2360: “hDC”的初始化操作由“case”标签跳过
TextOut(hDC, 0, 0, TEXT("HELLO"), 2);
EndPaint(hWnd, &ps);
break;
HDC hDC;
hDC = BeginPaint(hWnd, &ps);
// switch_statement2.cpp
// C2360 expected
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
switch( tolower( *argv[1] ) )
{
// Error. Unreachable declaration.
char szChEntered[] = "Character entered was: ";
case 'a' :
{
// Declaration of szChEntered OK. Local scope.
char szChEntered[] = "Character entered was: ";
cout << szChEntered << "a\n";
}
break;
case 'b' :
// Value of szChEntered undefined.
cout << szChEntered << "b\n";
break;
default:
// Value of szChEntered undefined.
cout << szChEntered << "neither a nor b\n";
break;
}
}