 <p>It really depends on what scope you want the iterator to have. Generally speaking, you want to restrict its scope as much as possible while still letting it to its job<sup>1</sup>.</p> <p>If you're only going to use it inside the body of the loop, then it's preferable to define it in the loop header, so its scope is restricted to the loop body.</p> <p>If you're going to use it after the end of the loop, then define it above the loop so it still exists after the end of the loop.</p> <p>Of course, you generally want to avoid the whole question, such as by using a standard algorithm or range-based for loop (usually with <code>auto</code> instead of specifying the type explicitly).</p> <hr> <p><sub> 1. The same applies in general, not just to iterators. </sub></p>