小编stu*_*t13的帖子

案例'p'||的问题 'P':C++中switch语句中的语法

我通过以下方式使用了switch语句:

   switch (ch){
   case 'P' || 'p': 
        goto balance;
        break;

   case 'r' || 'R':
        goto menu;
        break;

   default:
           cout<<"\t\tInvalid Choice!!"<<endl;
           system ("\t\tpause");
           system ("cls");
           goto menu;
           break;
           }
Run Code Online (Sandbox Code Playgroud)

但似乎以下语法有问题:

case 'r' || 'R'
Run Code Online (Sandbox Code Playgroud)

编译器抱怨"重复案例值".我的代码出了什么问题?

c++ syntax compiler-errors switch-statement

4
推荐指数
2
解决办法
281
查看次数

标签 统计

c++ ×1

compiler-errors ×1

switch-statement ×1

syntax ×1