[CSI] order of case evaluation in switch
Mikhail Nesterenko
mikhail at cs.kent.edu
Wed Feb 3 12:42:47 EST 2021
CSI students,
I promised to investiage this issue during the last lecture. So,
default in a switch matches only when none of the other cases
match. Its location in the list of cases is not important.
I have never seen this before, but it is legal.
int i;
cin >> i;
switch (i) {
default:
cout << "none matches"; break;
case 1:
cout << "one"; break;
case 2:
cout << "two"; break;
}
Thanks,
--
Mikhail
More information about the cs13001
mailing list