看一段C++代码
switch-case中,多个case嵌套,猜猜MinGW编译运行时,输出什么?
#include <iostream>
using namespace std;
int main() {
int b = 3;
switch (b) {
case 1: {
cout << "1" <<endl;
break;
case 2: {
cout << "2" << endl;
break;
case 3: {
cout << "3" << endl;
break;
}
}
}
}
}
答案:3
是什么原因导致的