Beginner C++: Why is this switch statement giving me an error?

This question already has an answer here:

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

  • C++ does not allow switches (or other similar code, such as goto ) to jump over initialisations . In the switch, both the Queue and the Stack are at the same scope, and it would be possible for the switch code not to initialise one (or both) of them in that scope, depending on the value being switched on. This isn't so for the if/else, where they are at different scopes.

    链接地址: http://www.djcxy.com/p/14792.html

    上一篇: 在switch语句中通过引用返回

    下一篇: 初学者C ++:为什么这个switch语句给我一个错误?