小编典典

C++ STL 中的 const_iterator 和非 const 迭代器有什么区别?

all

const_iteratora和 an有什么区别,iterator你会在哪里使用一个而不是另一个?


阅读 149

收藏
2022-08-29

共1个答案

小编典典

const_iterators 不允许您更改它们指向的值,常规iterators 可以。

与 C++ 中的所有内容一样,始终喜欢const,除非有充分的理由使用常规迭代器(即,您想使用它们不会const更改指向值的事实)。

2022-08-29