Beginner C++: Why is this switch statement giving me an error?
This question already has an answer here:
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.
上一篇: 在switch语句中通过引用返回