switch case语句里面不能定义对象
2018-07-29 本文已影响0人
shasha075
今天写代码时,第一次碰到switch语句发生错误,错误提示如下:
error: cannot jump from switch statement to this case label
原因:case语句里面不能定义对象,如果case语句中出现两条及以上(不含break)的语句,就要用大括号{}将语句包含,在花括号 “{ }”中定义的对象,那么该对象的作用域就局限在这对花括号里。

修改正确后:
