Run Time error while iterating over a vector
<p>I am Iterating over a vector that stores Point data type elements [x,y], And what i want to achieve at every iteration is to add first 4 point x elements and first 4 points y elements....The during the next iteration i want to do the same with the next 4 x &amp; y......and so on </p>

<p>1st iteration  1.x + 2.x + 3.x + 4.x
               1.y + 2.y + 3.y + 4.y</p>

<p>2nd iteration  5.x + 6.x + 7.x + 8.x
               5.y + 6.y + 7.y + 8.y</p>

<p>and so on.....................Hope my problem is clear</p>

<p>Sample code: </p>

<pre><code>double Pta; 
    double Ptb;
    Point  vect;
    float R1, R2;
    float resultant;
    vector&lt;Point&gt; vect_add;
    for(vector&lt;Point&gt;::iterator iter_a = Left_Arm_xy.begin()+1; iter_a != Left_Arm_xy.end(); ++iter_a)
    {

        if(center.y &lt;= 240)
        {
            vect.x = iter_a-&gt;x - (iter_a -1)-&gt;x;
            vect.y = iter_a-&gt;y - (iter_a -1)-&gt;y;

            vect_add.push_back(Point(vect.x,vect.y));


            for(vector&lt;Point&gt;::iterator iter_v = vect_add.begin(); iter_v != vect_add.end(); ++iter_v)
            {



                    R1 = iter_v-&gt;x + (iter_v +1)-&gt;x + (iter_v +2)-&gt;x + (iter_v +3)-&gt;x;
                    R2 = iter_v-&gt;y + (iter_v +1)-&gt;y + (iter_v +2)-&gt;y + (iter_v +3)-&gt;y;

                    resultant = sqrt(pow(R1,2) + pow(R2,2));



                    cout&lt;&lt;"Resultant: "" "&lt;&lt;resultant&lt;&lt;endl;

            }

        }
</code></pre>

<p>When i comet out the part where I am trying to add all the x's and y's the program works fine just like it did before.....Therefore the issue must me there..I guess the syntax is not right but am not the best programmer and couldn't this of whats wrong as there is no compiler warnings....the program just crashes at run time</p>

<p>Can anyone possibly see what I am doing wrong with this code
regards</p>

<p>Debug:
<img src="http://i.stack.imgur.com/PtU04.jpg" alt="enter image description here"></p>

<p>Sorry for just adding the photo of the Debug breakpoint but i think picture is worth 1000 words in this case :P</p>
