![]() |
Query in precedence
Hi
I was just running a snippet from this website. Code:
int a=10,b;But when i ran through VS 2005, I got 22,13,14,14. Am I missing anything?? Mesh |
Re: Query in precedence
The behaviour is undefined because you use side effect operators twice on the same variable in the same statement. Twice.
This means the behaviour is dependent on what the compiler writer felt like at the time and should be avoided. Increment a only once per statement and do instead something like: Code:
int b1=a++; |
| All times are GMT +5.5. The time now is 07:44. |