dimanche 3 mai 2020

Custom container traversal with range-based for loop

In C++, some STL containers like vector, map, string can be traversed by for loops with colon in it.

for instance:

for(auto c:v)

When I'm writing a custom container, can I make it traversed that way like Java (which only need to implement Iterable)?

Aucun commentaire:

Enregistrer un commentaire