表达式:双端队列迭代器不可递增(特殊情况 - 我无法弄清楚)
我有类似 deq.push_back(object)
的东西,它在源文件中工作正常,但在另一个文件中则不然 - 如果我在那里尝试相同的操作,我会在标题中收到运行时错误。怎么可能? deq
是代码工作的源文件中的全局变量。作为测试,我尝试在源文件之间交换全局声明和 extern,并且得到相同的结果,第二个源文件触发运行时错误。我在这里缺少什么?为什么我不能从那里使用push_back?
I have something like deq.push_back(object)
which works fine in a source file but not in another one - if I try the same operation there I get the runtime error in the title. How can it be possible? deq
is a global variable in the source file where the code works. Just as a test, I tried to swap the global declaration and the extern between the source files and I get the same result, the second source file triggers the runtime error. What am I missing here? Why I can't use push_back from there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否有可能已将 deq.push_back(object) 语句移动到循环内,从而修改容器使循环迭代器无效?
Is it possible that you have moved the
deq.push_back(object)
statement to within a loop and thus modifying the container invalidates the loop iterator?