title: Behaviour about const_cast<>
body: <p>I have written a small problem for checking the behavior of const_cast on const data member.</p>
  
  <pre><code>using namespace std;
  
  
       class myString{
           public:
                   myString(char * str)
                   {
                           p=str;
                   }
                   const char * getString(){
                           return p;
                   }
           private:
                   const char *p;
   } ;
  
  
  int main()
  {
          char *p=(char*)malloc(8);
          cin&gt;&gt;p;
          myString *m= new myString(p);
          char *s =const_cast&lt;char*&gt;(m-&gt;getString());
          s[6]='y';
          cout&lt;&lt;s&lt;&lt;endl;
          return 0;
  }
  </code></pre>
  
  <p>After running this program I give the out as "yogendra"  (a 8 letter string). and i got the output as "yogendya"
  Now my doubt. Through const_cast&lt;> we can override the behavior of the data member itself as here the string is const char* still after casting i can modify it.</p>