It's undefined !! Basically, in C and C++, if you read a variable twice in an expression where you also write it, the result is undefined. Don't do that. Another example is:
v[i] = i++;Related example:
f(v[i],i++);Here, the result is undefined because the order of evaluation of function arguments are undefined.
You can even check it from Bjarne's own blog on C++ FAQs.
本文介绍了一个C++中自定义栈类的实现,并通过一个具体的例子展示了在使用表达式时可能遇到的未定义行为问题。文章强调了在同一个表达式中多次读取并修改同一变量会导致不可预知的结果。
7185

被折叠的 条评论
为什么被折叠?



