LittleDriver
LittleDriver

Reputation: 107

what's the object's type in Relationship between operation?

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?

Upvotes: 0

Views: 51

Answers (1)

Emil Laine
Emil Laine

Reputation: 42828

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.

Upvotes: 3

Related Questions