Iterate through a C++ Vector using a 'for' loop

后端 未结 12 1731
天命终不由人
天命终不由人 2020-11-29 16:02

I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the first parameter

12条回答
  •  半阙折子戏
    2020-11-29 16:32

    With STL, programmers use iterators for traversing through containers, since iterator is an abstract concept, implemented in all standard containers. For example, std::list has no operator [] at all.

提交回复
热议问题