What is the purpose of STL iterators? Why have programmers created this concept at all?
What is the purpose of STL iterators? Why have programmers created this concept at
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Iterators allow you to separate algorithms from the container. As long as you have a start and end iterator, and know the capabilities of the iterator (random access etc) you can do operations on the range specified by the iterators. For example, see
std::for_each,std::transform. This way you can implement just one version of an algorithm rather than needing to write a new one for each container on which you wish it to operate.