How to return the last three values of a vector?
<p>I'd like to place the last three values of vector <strong>v_2</strong> in three variables (one value per variable).
Is there a faster or simpler way to do this?   </p>

<pre><code>struct Desempenho {
double maximo;
};  

 double ultimo, penultimo, antepenultimo;
 Desempenho d;
 int n (0);
 vector&lt;Desempenho&gt; v_2;
 d.maximo=1.1;
 v_2.push_back(d);
 d.maximo=2.2;
 v_2.push_back(d);
 d.maximo=3.3;
 v_2.push_back(d);
 d.maximo=4.4;
 v_2.push_back(d);
 d.maximo=5.5;
 v_2.push_back(d);

 for (vector&lt;Desempenho&gt;::const_reverse_iterator rit = v_2.rbegin(); rit != v_2.rend(); ++rit) {
     cout &lt;&lt; "XXXX " &lt;&lt; n &lt;&lt; endl;
     if (n==0) ultimo = rit-&gt;maximo;
     else if (n==1) penultimo = rit-&gt;maximo;
     else if (n==2) antepenultimo = rit-&gt;maximo;
     else break;
     ++n;
     }

 cout &lt;&lt; ultimo &lt;&lt; " " &lt;&lt; penultimo &lt;&lt; " " &lt;&lt; antepenultimo &lt;    &lt; endl;
</code></pre>
