Order of operations/precedence

could someone explain to me why the answer would be 3?

1
2
3
4
5
  int a = 5;
  
  a -= a-- - --a;

  cout << a;

Last edited on
The code has undefined behaviour.
Are you saying its not valid? because its valid.
a -= a--(5) - --a(4-1)
5 -= 5 - 3
5 -= 2
3

http://stackoverflow.com/a/4706225/2089675

I have my doubts however that this is actually how it works, but if it does the way I showed is how it would be evaluated
Last edited on
Topic archived. No new replies allowed.