title: Arrays as address constants in functions
body: <p>I'm teaching myself C++ and had some questions about arrays and pointers.  My understanding is that arrays are really just pointers, however, arrays are <strong>address constants</strong> which cannot be changed.  </p>
  
  <p>If this is the case, I was wondering why in my function <code>show2()</code> I was able to change the address of the pointer <code>list</code>.  Unlike variables, I thought arrays are passed by reference so I was expecting a compiler error when calling function <code>show2()</code> since I incremented the address of <code>list</code>.  But the code works just fine.  Can someone please explain?</p>
  
  <p>Thank you!</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  
  using namespace std;
  
  void show1(double *list, int SIZE)
  {
      for(int i=0; i &lt; SIZE; i++)
      {
          cout &lt;&lt; setw(5) &lt;&lt; *(list+i);
      }
      cout &lt;&lt; endl;
      return;
  }
  
  void show2(double *list, int SIZE)
  {
      double *ptr = list;
  
      for(int i=0; i &lt; SIZE; i++)
          cout &lt;&lt; setw(5) &lt;&lt; *list++;
      cout &lt;&lt; endl;
      return;
  }
  
  int main()
  {
      double rates[] = {6.5, 7.2, 7.5,  8.3, 8.6, 
                        9.4, 9.6, 9.8, 10.0};
      const int SIZE = sizeof(rates) / sizeof(double);
  
      show1(rates, SIZE);
      show2(rates, SIZE);    
      return 0;
  }
  </code></pre>