1put everything in the case x: under {} brackets
2metti tutto quello nel case x: sotto le parentesi {}
1switch (choice)
2{
3 case 1: get_two_numbers(x, y);
4 //* vv here vv *
5 int sum = add(x, y);
6 //* ^^ here ^^ */
7 cout << x << " + " << y << " = " << sum << endl;
8 break;
9 case 2: get_two_numbers(x, y);
10 //* vv here vv */
11 int diff = subtract(x, y);
12 //* ^^ here ^^ */
13 cout << x << " - " << y << " = " << diff << endl;
14 break;
15 default:;
16}
1switch(foo) {
2 case 1:
3 int i = 42; // i exists all the way to the end of the switch
4 dostuff(i);
5 break;
6 case 2:
7 dostuff(i*2); // i is *also* in scope here, but is not initialized!
8}