can you have a situation like

or does it have to beCode:`int a = 3;`

int b = 3;

int c = 3;

if (a == b == c){

cout<< "yes";

}

Code:`if (a == b && a == c){`

cout<< "yes";

}

Printable View

- 01-10-2008MegaManZZquick question regarding the '==' sign.
can you have a situation like

Code:`int a = 3;`

int b = 3;

int c = 3;

if (a == b == c){

cout<< "yes";

}

Code:`if (a == b && a == c){`

cout<< "yes";

}

- 01-10-2008laserlight
It can be the former (but you may get a result which you did not expect), but it should be the latter.

- 01-10-2008matsp
The second one will do what you want. The first one does:

Code:`a == (b == c)`

Code:`temp = (b == c); // Makes a value of 0 or 1. (parenthesis not strictly necessary)`

a == temp;

Mats - 01-10-2008Dino
So, to clarify (for myself),

Code:`a==b==c ;`

Todd - 01-10-2008laserlightQuote:

results in false, even through a==b is true and b==c is true. Correct?