 <p>The list class is a linked list, you cannot directly index into it. Also, iterators are not indices, + just doesn't makes any sense.</p> <p>However, in theory, you should be able to copy an iterator, if you change q = mboxes.begin() + p into q = p it should set q to be an iterator pointing to the same location of p, and that may just solve your problem.</p> <pre><code>for (list&lt;Box&gt;::iterator p = mBoxes.begin(); p != mBoxes.end(); p++) { for (list&lt;Box&gt;::iterator q = p, q++; q != mBoxes.end(); q++) { if (p-&gt;isIntersecting(q)) { p-&gt;changeDirection(); q-&gt;changeDirection(); } } } </code></pre> <p>the q++ should simply skip the current element so you don't compare an item against itself.</p>