Friday, May 11, 2012

Assignment operator in RVALUE

I came across a line of code which looked a bit strange to me. It reads like this..
x= m * (n=7);
The above code is actually equivalent to
n=7
x=m*n

Actually c++ supports using assignments on the right hand side of assignments operator. And we are all familiar with that. I bet you must have seen assignments like this…
a=b=c;
This and the previous code follows the same rule.

No comments:

Post a Comment