Understanding Iterators in the STL

后端 未结 6 1407
悲&欢浪女
悲&欢浪女 2020-12-08 06:07

What exactly are iterators in the C++ STL?

In my case, I\'m using a list, and I don\'t understand why you have to make an iterator std::list

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 06:48

    An iterator is to an STL container what a pointer is to an array. You can think of them as pointer objects to STL containers. As pointers, you will be able to use them with the pointer notation (e.g. *iElementLocator, iElementLocator++). As objects, they will have their own attributes and methods (http://www.cplusplus.com/reference/std/iterator).

提交回复
热议问题