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";
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With