原因是在switch 中有初始化的工作。
在switch 语句中不可以有定义部分。如果有定义,如初始化的时候,必须把定义部分用{ } 括起来。
例如:
这段代码 case 后的代码增加了一个括号,括起来,没有这对括号就会报错
case binaryop:
{
bool end_right=false;
do
{
if(delayed_operations.empty())end_right=true;
else
{
prior=delayed_operations.top();
if(prior.Kind()==leftparen)end_right=true;
else if(prior.Priority()<current.Priority())end_right=true;
else if(current.Priority()==6)end_right=true;
else answer.Put_token(prior);
if(!end_right) delayed_operations.pop();
}
}while (!end_right);
delayed_operations.push(current);
break;
}
default: cout<<" 你的输入格式可能不正确!"<<endl;break;