C ++迭代器取消引用和前缀递增/递减样式? *-好的样式是明智的吗? [英] C++ Iterator dereference and prefix increment/decrement style? Is *--Iter ok style wise?
本文介绍了C ++迭代器取消引用和前缀递增/递减样式? *-好的样式是明智的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用C ++迭代器进行编码时,如果要使先前的值指向迭代器所指向的内容,则会写出以下内容:
In coding with C++ iterators if you wanted to get the previous value to what an iterator points to would you write:
*--Iter
或者您认为像这样添加括号会更好:
or would you think it better to add parentheses like so:
*(--Iter)
?
推荐答案
就程序的正确性而言,这无关紧要.但是我总是将其表示为*(--Iter)
,因为与*--Iter
相比,它更易于记录,更易于为人类所理解.
It doesn't matter as far as program correctness is concerned. But I always express this as *(--Iter)
because this is more self-documenting and easier to understand to human beings than *--Iter
.
这篇关于C ++迭代器取消引用和前缀递增/递减样式? *-好的样式是明智的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文