What is x after “x = x++”?

后端 未结 17 1326
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 06:26

What happens (behind the curtains) when this is executed?

int x = 7;
x = x++;

That is, when a variable is post incremented and assigned to

17条回答
  •  长情又很酷
    2020-11-21 06:58

    The incrementing occurs after x is called, so x still equals 7. ++x would equal 8 when x is called

提交回复
热议问题