Hi,
I just lost a few hours trying to make a program work because i was thinking it returned illogical values, because i printed them the wrong way
The code
std::cout<<function1()<<fucntion1()<<std::endl
printed "01", while the first call of the function returns true and the second call returns false (boolean return type)
Can anyone explain this to me? Is the text to output to cout evaluated from right to left, so the functions are executed in reverse order of their printing order?
Can i deduce that cout prints the output only when it has fully evaluated the value of the cout line (else i would have had messsagefromInsideFunction1 0 messageFrominsideFunction1 1), or is it also something not guaranteed?
The order of evalution of sub-expressions in argument lists is undefined. Usually C/C++ compilers evaluates such sub-expressions from the right to the left according to the convention of passing arguments in the stack to C functions.
@bartoli
Can i deduce that cout prints the output only when it has fully evaluated the value of the cout line (else i would have had messsagefromInsideFunction1 0 messageFrominsideFunction1 1), or is it also something not guaranteed?
You can rewrite the original statement as two or even three statements