Iterator and reverse Iterator
<p>I am quiet fresh to C++ and programming in general, I am writing an OpenCv application in C++ environment. </p>

<p>WHAT I AM TRYING TO ACHIEVE:</p>

<p>OK, so I got some Rectangles center points stored in a vector, Now I am using a reverse Iterator to iterate over the vector with rectangle center points and store every 10th center point into new vector.</p>

<p>I then again iterate over that new vector that stores every 10th rectangle center point with normal iterator, And I want to subtract 1st element from 2nd element 3rd element from 4th element and so on, the subtraction results, I want to store into another new vector :D</p>

<p>It might be slightly confusing to some people; I am confused, myself, that is why below I will add the code I have written.</p>

<pre><code>vector&lt;Point&gt; Rightarm;
vector&lt;Point&gt; Leftarm;

vector&lt;Point&gt;::reverse_iterator RightMovmentIter;
vector&lt;Point&gt;::reverse_iterator LeftarmMovmentIter;

vector&lt;Point&gt; RightTracking;
vector&lt;Point&gt; LeftTracking;

for(RightMovmentIter = Rightarm.rbegin(); RightMovmentIter != Rightarm.rend(); RightMovmentIter+=10)
{
    RightTracking.push_back(*RightMovmentIter);
}

for(LeftarmMovmentIter = Leftarm.rbegin(); LeftarmMovmentIter != Leftarm.rend(); LeftarmMovmentIter+=10)
{
    LeftTracking.push_back(*LeftarmMovmentIter);
}

vector&lt;Point&gt;::iterator RresultIter;
vector&lt;Point&gt;::iterator Leftresult_Iter;
vector&lt;Point&gt; summery;

for(RresultIter = RightTracking.begin(); RresultIter != RightTracking.end(); RresultIter++)
{
    summery = *RresultIter - *RresultIter++;
}
</code></pre>

<p>PROBLEMS:</p>

<p>1st Problem is that when I run the program I get run time error I belief it's because at the begining of the vector Rightarm &amp; Leftarm do not have 10 elements and when the Iterator runs through it and is trying to look for the 10th element i cant....HOW do I work this out then?</p>

<p>2nd Problem is to do with this line summery = *RresultIter - *RresultIter++; I know it's wrong and this is the best attempt I could of think of, but what I want to do is to subtract 1st element from 2nd element and store it in summery element...</p>

<p>Hopefully This describes my problem well enough for the readers 
Regards</p>
