std::cout statements evaluation order [duplicate]

谁说胖子不能爱 提交于 2019-12-02 07:35:57
Baum mit Augen

Nothing did go wrong, but the pops get (in your case) evaluated from right to left if you put them all in one std::cout line. In general. the evaluation order is unspecified. For more detail on this see here.

So you correctly get the elements in reverse order of insertion and then -1 and then print them reversed.

In the last line of your code, you make several function calls (hidden, but each << operator is actually a function call). The evaluation of the parameters to these function calls is unspecified. So it is unspecified which "pop() function is called first.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!