This code won't work, I'm assuming it's because the case can't be a logical statement.
The actual program I'm working on would use a much more complex switch than this, this is simply a small example of the concept.
My question is, what's the easiest way to accomplish similar results?Code:#include <iostream> using namespace std; int main( ) { int x = 1; switch (x) { case (0 || 1): cout << "X is either 0 or 1" << endl; break; case (1 || 2): cout << "X is either 1 or 2" << endl; break; case (2 || 3): cout << "X is either 2 or 3" << endl; break; } system("pause"); return 0; }
Ideally, I'd want the output generated to be
X is either 0 or 1
X is either 1 or 2
Thanks



LinkBack URL
About LinkBacks




