It is very likely that in the C++ implementation you are using one of the other headers you have included includes <iterator>
. Do not expect this to be the same in other C++ implementations or even the next revision of the implementation you are using.
Best practice is to always include all headers you need in whichever file needs them.
This prevents problems and mystery bugs in the future should an include be removed from another included header or what looks like an include turns out to merely be a forward declaration of key classes or functions.
This also assists greatly in portability. The next tool chain you use could be laid out differently, not to mention other programmers who may inherit your code or wish to use it in another project.
From the student coder point of view, it really sucks when you hand in code that compiles on your PC, but not the marker's.
This sounds silly and repetitive, but a properly written header has include guards to prevent the header from being included more than one in any translation unit.
This also leaves breadcrumbs for other developers who can see at a glance what headers are used by a given file. For this reason do not include everything just in case you might need it. Creating a monolithic list of unnecessary headers also slows compilation.