Reputation: 639
Here is a block of code. Can anyone explain what it means to have a pair of numbers enclosed inside parentheses. (This is in C++.)
int a = 2, b = 2, c = 3, d = 1;
if((a,b)<(c,d))
cout<<"case1"<<endl;
else
cout<<"case2";
Upvotes: 4
Views: 941
Reputation: 269
Or if the value are changing or taken as an input by user you can use &&
(and), ||
(or) logical operators to sort out your codes
if ((a<c) && (b<d))
or
if ((a<c) || (b<d))
That way you can make cases the way you like. Check about operators here http://www.cplusplus.com/doc/tutorial/operators/
Upvotes: -2
Reputation: 179452
That's the comma operator; it evaluates the thing on the left, throws the result out, and returns the result on the right. Since evaluating an int
variable has no side-effects, that if
is semantically equivalent to
if(b < d)
Upvotes: 13