I = ++ i和++ I的区别 [英] Difference between i = ++i and ++i

查看:99
本文介绍了I = ++ i和++ I的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc\">Could谁能解释这些不确定的行为,(I = I + + + + I,I = I ++等&hellip;)

什么是 I = ++我之间的区别; ++我; ,其中 I 是值的整数 10

What is the difference between i = ++i; and ++i; where i is an integer with value 10?

据我既做两个前pressions完成 I = 11 I 即同样的工作C $ C>。

According to me both do the same job of incrementing i i.e after completion of both the expressions i =11.

推荐答案

调用未定义行为而 ++我; 没有。​​

C ++ 03 [第5/4]说:的previous和下一个序列点之间的标量对象,由一个前$ p的评价已经修改最多的一次存储的值$ pssion

C++03 [Section 5/4] says Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression.

I = ++我 I 正在修改两次[pre-增量和分配]没有任何干预序列点,这样的行为在C和C ++中。

In i = ++i i is being modified twice[pre-increment and assignment] without any intervening sequence point so the behaviour is Undefined in C as well as in C++.

I = ++我很好用C ++定义0X:)

However i = ++i is well defined in C++0x :)

这篇关于I = ++ i和++ I的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆