On Apr 22, 10:24 pm, Robert <irishhac...@gmail.comwrote:
Is that valid C or C++ syntax?
Or must one do x<y && y<z ?
Please do not write the main body of the article into the article
title.
As syntax goes the following is correct: if ( x < y < z ) fctn1() ;
however, it may not produce what you expect.
If x, y and z are int values, then x < y evaluates to a bool, is
converted to 0 for false, 1 for true in integral promotion, then
compared to z.
Try the following code. Your compiler should produce appropriate
warnings.
#include <iomanip>
#include <iostream>
int main()
{
std::cout << std::boolalpha << static_cast<bool>( 3 < 2 < 1 ) <<
std::endl;
std::cin.get();
}