switch statement

is it possible to compare value in switch statement?
i.e: a > b

is it possible??
You really shouldn't need to, the comparison operators return a bool value so an if else should be enough.
but is it possible to compare in switch statement?
No, I don't believe that a switch statement will evaluate 'bool'. I'll be honest, I didn't verify this but it shouldn't work.
but is it possible to compare in switch statement?
Yes:
1
2
3
4
5
6
7
8
9
10
11
  int a = 0, b = 1;
  switch(a > b)
  {
  case true:
    ++a;
    break;
  case false:
    ++b;
    break;
  }
  std::cout << a << std::endl << b << std::endl;
I guess that would to do it, I thought the OP meant for each 'case' statement to be a separate evaluation.
Topic archived. No new replies allowed.