I just solved 1st exercise on learncpp, chaper 7.8. I tested their version of switch loop and it works, but I wonder it's without break
, shouldn't in this case such code cause undesired behavior? When can I leave out break
?
Here is my version(which also works correctly):
switch (op)
{
case '+': {
return add;
break;}
case '-': {
return subtract;
break;}
case '*': {
return multiply;
break;}
case '/': {
return divide;
break;}
default: ;
}