c语⾔case多个常量,switch语句多字符常量我正在尝试将其转换为switch语句
if (codeSection == 281)
cout << "bigamy";
else if (codeSection == 321 || codeSection == 322)
cout << "selling illegal lottery tickets";
else if (codeSection == 383)
cout << "selling rancid butter";
else if (codeSection == 598)
cout << "wounding a bird in a public cemetery";
else
cout << "some other crime";
/
/ Actual switch statement
switch (codeSection)
{
case '281':
cout << "bigamy" << endl;switch case判断字符串
break;
case '321':
case '322':
cout << "selling illegal lottery tickets" << endl;
break;
case '383':
cout << "selling rancid butter" << endl;
break;
case '598':
cout << "wounding a bird in a public cemetery";
break;
default:
cout << "some other crime"<< endl;
}
编译器说switch语句多字符常量,并给我⼀个黄⾊警告,但仍然编译.我的问题是假设只是以char形式?像案例'2'

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。