title: Changing constant pointer's address
body: <p>I'm trying to understand one thing.</p>
  
  <p>I know I can't change constant pointer's value, but I can change its address, if I initialize a pointer the following way:</p>
  
  <pre><code>int foo = 3;
  const int *ptr = &amp;foo;
  *ptr = 6; // throws an error
  int bar = 0;
  ptr = &amp;bar; // foo == 0
  </code></pre>
  
  <p>Now, let's say I declare (/define, I never remember which one) a function:</p>
  
  <pre><code>void change(const int arr[], int size);
  
  int main() {
     int foo[2] = {};
     change(foo, 2);
     std::cout &lt;&lt; foo[0];
  }
  
  void change(const int arr[], int size) {
     // arr[0] = 5 - throws an error
     int bar = 5;
     arr = &amp;bar;
  }
  </code></pre>
  
  <p>The last line in the code above doesn't throw any errors. However, when the function is over and I display the first element, it shows 0 - so nothing has changed.</p>
  
  <p>Why is that so?</p>
  
  <p>In both situations I have constant pointers, and I try to change its address. In the first example it works. In the second one it doesn't.</p>
  
  <hr>
  
  <p>I also have another question. I've been told that if I want to pass two-pointers type to the function, const keyword won't work as expected. Is that true? And if so, then what's the reason?</p>