I have a switch statement:
swtich(x)
{
case 1:
...
break;
case 2:
...
break;
}
I want to put the ... code in a function but I want to put the break too… So I want something like that
void func()
{
...;
break;
}
swtich(x)
{
case 1:
func();
case 2:
func();
}
Break gives error (I know why) but what I can do?
You can’t. Best you can do is:
See here for a discussion of what break is for:
If you put it in a function, how will it know which loop or switch statement it’s supposed to apply to?