title: When Declaring a Reference to an Array of Ints, why must it be a reference to a const-pointer?
body: <p>Note: I am using the g++ compiler (which is I hear is pretty good and supposed to be pretty close to the standard).</p>
  
  <hr>
  
  <p>Let's say you have declared an array of ints:</p>
  
  <pre><code>int a[3] = { 4, 5, 6 };
  </code></pre>
  
  <p>Now let's say you really want to declare a reference to that array (nevermind why, other than the Bjarne says the language supports it).</p>
  
  <p>Case 1 -- If you try:</p>
  
  <pre><code>int*&amp; ra = a;
  </code></pre>
  
  <p>then the compiler balks and says:</p>
  
  <pre><code>"invalid initialization of non-const reference of type `int*&amp;' from a temporary of type `int*'"  
  </code></pre>
  
  <p>First things first, why is 'a' a temporary variable (i.e. doesn't it have a place in memory?)...  </p>
  
  <p>Anyway, fine, whenever I see a non-const error, I try to throw in a const... </p>
  
  <p>Case 2 -- if you try:</p>
  
  <pre><code>int*const&amp;rca = a;  //wish I knew where the spaces should go (but my other post asking about this sort of protocol got a negative rank while many of the answers got ranked highly -- aha! there are stupid questions!) 
  </code></pre>
  
  <p>Then everything is cool, it compiles, and you get a reference to the array.</p>
  
  <p>Case 3 -- Now here is another thing that will compile:</p>
  
  <pre><code>int* justSomeIntPointer = a;  //LINE 1
  int*&amp; rpa = justSomeIntPointer;  //LINE 2
  </code></pre>
  
  <p>This also gives you a reference to the original array.</p>
  
  <p>So here is my question:  At what point does the name of a statically declared array 
  become a const-pointer?  I seem to remember that the name of an array of ints is also a pointer-to-int, but I don't remember it ever being a const-pointer-to-int...</p>
  
  <p>It seems like Case 1 fails because the reference declared (ra) is not to a const-pointer, which may mean that 'a' was already a const-pointer-to-int to begin with.</p>
  
  <p>It seems like Case 2 works because the reference declared (rca) is already a const-pointer-to-int.</p>
  
  <p>Case 3 also works, which is neat, but why?  At what point does the assumed pointer-to-int (i.e. the array name 'a') become a const-pointer?  Does it happen when you assign it to an int* (LINE 1), or does it happen when you assign that int* to a int*&amp; (LINE 2)?</p>
  
  <p>Hope this makes sense.  Thanks.</p>