As iteritems ranged for?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
19 views
To use a ranged for the container must meet certain conditions. In particular, for a container it is possible to define functions begin( __range ) and end( __range ), available at ADL.

But what if linear iteration over the container is impossible? In this case, it should return the functions begin and end?
by | 19 views

2 Answers

0 like 0 dislike
Iterators are an abstraction created in order that you could the same approach apply to bypass a fundamentally different containers.
The implementation of iterator is a class that implements a particular interface, as you wrote. Inside the class, implement it as you want, save the state of the reference counters in the private data members of the iterator class, etc., etc. begin with the end should return a reference to the iterator. begin and end are not included in the iterator interface.
Teach materiel.
by
0 like 0 dislike
I advise you to go to the documentation and read about the types of iterators and what it is.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
4 answers
asked Mar 25, 2019 by nsinreal
110,608 questions
257,187 answers
0 comments
40,796 users