我正在编写一个示例c ++程序,但在切换案例中初始化变量时,它给出了编译错误。
如果我宣布它像int x;它没有给出错误,当我在一个案例块中也这样做时也会发生同样的事情。
#include <iostream>
using namespace std;
int main()
{
int x=3;
switch(x)
{
int y=10;
case 2:
cout<< "c++";
}
}
这给了我error: jump to case label [-fpermissive]
任何人都可以澄清我的怀疑