how returning reference work here
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8924966/returning-a-reference-can-work">Returning a reference can work?</a>  </p>
</blockquote>



<p>Why this code works (<code>matrix</code> is a class):</p>

<pre><code>const int max_matrix_temp = 7;
matrix&amp;get_matrix_temp()    
{
   static int nbuf = 0;  
   static matrix buf[max_matrix_temp];  

   if(nbuf == max_matrix_temp)    
      nbuf = 0;  

   return buf[nbuf++];
} 

matrix&amp; operator+(const matrix&amp;arg1, const matrix&amp;arg2)
{  
    matrix&amp; res = get_matrix_temp();
    //...  
    return res;
}
</code></pre>

<p><strong>What is <code>buf</code> doing here and how does it save us from having garbage values and why it is declared <code>static</code> ?</strong> please enlighten properly..</p>
