Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • str can not be used after the close brace of the scope. What is the sense to enter a string and it can not longer be used?
    – Klaus
    Commented May 10, 2020 at 7:17
  • 1
    This is a small example. It is not used in the original code as well. But one can do all the processing needed for choice == 2 inside the switch statement: calling functions, pushing str to vectors, etc. If you need to access str strictly after the switch statement, it's a smell: there are no guarantees that str will have a reasonable value after the switch in general.
    – yeputons
    Commented May 10, 2020 at 7:36