Just FUN :D



  • Hi dears, please look this...

    @
    if ( false==false==false )
    qDebug()<<"Ding Ding !"; //UNREACHABLE CODE
    @

    i think that it should be ok and print my message because of
    FALSE is FALSE and FALSE will be FALSE!!!
    compiler work with it's result which it returned. but why?
    i know we need the result for if but... let's speak about it...



  • Hi,
    Off course this compiles (will give Wparentheses warning). The result will be not printing the output! Very simpel, the == operator does a compare of the first two elements (false==false) this will return true. Then do the compare of true==false -> result false, so your code does:
    if (false)
    {
    }
    So this does not work and will not print the output



  • That's great! So if FFF is false, test FTF, you'll be surprised!
    How does a brain works to find such things!
    Very amusing.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.