Newbie question. please help me :D

Jun 24, 2013 at 8:43am
If the code is like this:
1
2
3
4
5
6
7
8
9
10
11
12
cout << "Please type 1 for ----" << endl;
cout << "Please type 2 for ----" << endl;
cin >> type;
	
switch(type)
{
case 1:
etc....

case 2:
etc....
}

is it possible to jump from case 2 to case 1? help me answer this please? i need it badly.
Jun 24, 2013 at 8:52am
any form of "jumping" is bad practice, but you can use fall through by omitting a break.


1
2
3
4
5
6
7
8
9
10
11
12
switch(type)
{
case 3:
      // blah
      break;
case 2:
      // blah
             // missing break statement, will fall through to "case 1"
case 1:
     // blah
     break;
}


Jun 24, 2013 at 8:54am
ohh yeah i forgot the break :) thank you so much.
Topic archived. No new replies allowed.