title: casting away the constness using const_cast
body: <p>No. This question in NOT duplicate of 
  <a href="https://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-const-cast-and-reinterpret-cast-be-used">When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?</a></p>
  
  <p>The question asked here is no ways similar to the link described as duplicate.</p>
  
  <p><strong>First question :</strong> 
  I am using const_cast below for two cases. one of it works. the other doesn't.</p>
  
  <p><strong>1.</strong> <strong>int* const</strong>     //Works.</p>
  
  <p>In this syntax the address to which the variable would point to cannot be changed. So i used const_cast as below and it works:</p>
  
  <pre><code>`
  int j=3;
  int *k=&amp;j;
  int *m=&amp;j;
  int* const i=k; 
  const_cast&lt;int*&gt;(i)=m; //OK: since i=m would not work so cast is necessary`
  </code></pre>
  
  <p><strong>2.</strong> <strong>const int*</strong>  //Doesn't work.</p>
  
  <p>The address being pointed to can be changed however the value cannot be changed(though can be changed by making the variable point to different address). The const_cast i am using doesn't seem to work here:</p>
  
  <pre><code>`
  int j=9;
  int *k=&amp;j;
  const int* i1=0;
  i1=k; //OK
  //*i1=10;//ERROR.`
  </code></pre>
  
  <p>So i tried to typecast as below through various ways but nothing works:</p>
  
  <pre><code>const_cast&lt;int*&gt;(i1)=10;
  const_cast&lt;int*&gt;(*i1)=l;
  *i1=const_cast&lt;int&gt;(l);
  *i1=const_cast&lt;int*&gt;(10);
  </code></pre>
  
  <p><strong>Second question:</strong>
  Are all the casts available only for pointers and references?
  Is the following example not valid where no pointer or reference is in picture?</p>
  
  <pre><code>const int a=9;
  int b=4;
  const_cast&lt;int&gt;(a)=b; //cannot convert from 'int' to 'int'. why is compiler
                        //trying to convert from int to int anyways or fails         
                        //when both the types are same.
  </code></pre>