if ( (i == j) == k )
i == j -> true -> 1
1 != 123
To avoid that:
if ( i == j && j == k ) {
Don’t do this:
if ( (i==j) == (j==k))
You’ll get for i = 1, j = 2, k = 1 :
if ( (false) == (false) )
… hence the wrong answer 😉
More Related Contents:
- Where are static variables stored in C and C++?
- What is the difference between the dot (.) operator and -> in C++? [duplicate]
- What does the question mark character (‘?’) mean in C++?
- What’s the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__?
- Implementing comparison operators via ‘tuple’ and ‘tie’, a good idea?
- how does array[100] = {0} set the entire array to 0?
- How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?
- What is special about numbers starting with zero?
- Best compiler warning level for C/C++ compilers? [closed]
- C++ [] array operator with multiple arguments?
- Overloading friend operator
- Do unused functions get optimized out?
- Making operator
- Can I separate C++ main function and classes from Objective-C and/or C routines at compile and link?
- What is difference between sjlj vs dwarf vs seh?
- Template within template: why “`>>’ should be `> >’ within a nested template argument list”
- The copy constructor and assignment operator
- The tilde operator in C
- Update GCC on OSX
- Inadvertent use of = instead of ==
- Understanding stack frame of function call in C/C++? [closed]
- Why is the phrase: “undefined behavior means the compiler can do anything it wants” true?
- Template instantiation details of GCC and MS compilers
- What is the value category of the operands of C++ operators when unspecified?
- C++ string literal data type storage
- c++ sizeof() of a class with functions
- What is the difference between “::” “.” and “->” in c++ [duplicate]
- What does ‘**’ mean in C?
- Does the unary + operator have any practical use?
- _iterator_debug_level value ‘0’ doesn’t match value ‘2’