Why can't variables be declared in a switch statement?

后端 未结 23 2967
一生所求
一生所求 2020-11-21 05:15

I\'ve always wondered this - why can\'t you declare variables after a case label in a switch statement? In C++ you can declare variables pretty much anywhere (and declaring

23条回答
  •  梦如初夏
    2020-11-21 06:02

    I believe the issue at hand is that is the statement was skipped, and you tried to use the var elsewhere, it wouldn't be declared.

提交回复
热议问题