case
suggest changeIntroduces a case label of a switch statement. The operand must be a converted constant expression of the promoted type of the condition. When the switch statement is executed, it jumps to the case label whose value equals the condition, if any.
char c = getchar();
bool confirmed;
switch (c) {
case 'y':
confirmed = true;
break;
case 'n':
confirmed = false;
break;
default:
std::cout << "invalid response!\n";
abort();
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents