title: assign pointer to constant pointer in c++
body: <p>I have a constant pointer <code>cp</code> that points to <code>A</code> and a non constant pointer <code>p</code> that points to <code>B</code>. I wold say that I can assign <code>cp</code> to <code>p</code>, i.e. <code>p=cp</code> because in this way both <code>cp</code> and <code>p</code> point to <code>A</code> and I cannot do the opposite: <code>cp=p</code>, because in this way I am saying that <code>cp</code> should point to <code>B</code> but <code>cp</code> is a constant pointer so I cannot change what it is pointing to.
  I tried with this simple code but the result is the opposite, can someone explain me what is the correct version please?</p>
  <pre><code>std::vector&lt;int&gt; v;
  v.push_back(0);
  auto cp = v.cbegin(); // .cbegin() is constant 
  auto p = v.begin(); // .begin() is non constant 
  </code></pre>
  <p>now if I write <code>cp=p</code> the compiler doesn't mark as error, but if I write <code>p=cp</code> the compiler marks the error.</p>