How would you do this in C++? For example I’m trying to trigger a program exit both if the user presses ESC or ‘q’ or ‘Q’.
I’ve tried looking for it, but I found no syntax for it in C++. I know how to do it with if-else, but is it possible with switch – case? Of course I can just make a function and call it from two separate case, but is there a way to do it just by combined case statement?
For example that’s what I’m looking for (of course not working):
void keyboard( unsigned char key, int x, int y )
{
switch( key )
{
case ( 27 || 'q' || 'Q' ):
exit( 0 );
break;
case 'a': ...
case 'b': ...
}
}
Cases fall through without a break: