0

i read the c++ primer, i found a example like this:

int i = 1, j = 2, k = 3;

if(i < j < k)
    return 0;

we all know the result's type of Relationship between operation is bool, so "i < j"'s result is true. when the previous result and k to calculate, the previous result's type will change to int?

emlai
  • 37,861
  • 9
  • 87
  • 140
LittleDriver
  • 107
  • 2
  • 8

1 Answers1

3

Yes, the true from i < j will be implicitly converted to 1. Then 1 < k yields true as well.

A false would be converted to 0.

emlai
  • 37,861
  • 9
  • 87
  • 140