I was asked this question in an interview. I replied that it was a conditional construct because
So is my answer right or wrong, is there a better answer?
Also he asked me the reason why break;
statements work with switch-case since, break;
only works with loops.
This question I could not answer.
In C++
switch
is selection-statement
n3376 6.4/1 and 6.4.2 is about switch
selection-statement:
...
switch ( condition ) statement
break
is jump-statement
n3376 6.6.1/1
The break statement shall occur only in an iteration-statement or a switch statement and causes termination of the smallest enclosing iteration-statement or switch statement; control passes to the statement following the terminated statement, if any.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With