Hi,
Could someone please explain how the following ends up outputting 0?
I interpret this as follows.Code:#include <iostream>
int main()
{
int a=0;
std::cout << a++ + a++ << std::endl;
return (0);
}
Compiler reads from right to left. So first the a++ on the right gets processed. Since its postfix, operator + gets 0. and then a is set to 1. Now the a++ on the left gets processed. a=1 is passed to +, and then a is incremented by 1 to 2. So the final result should be 1.
cheers,
pooya
