i think constant pointer only means the address it's representing is constant i mean can not be changed but of-course the value contained in variable d which is not constant can be changed. If i am wrong correct me.
On Mon, Aug 8, 2011 at 7:23 AM, mohit verma <[email protected]> wrote: > In c++ > > int d=1; > const int *const ptr = &d; means ptr is const ptr to const object .So > neither ptr nor d can be changed. But > > when i do - > d=5; > cout<<d<<" "<<*ptr; > the values are changed. Why is it so? > Moreover doing something like : *ptr=5 gives error. Can someone explain > internals here? > -- > ........................ > *MOHIT VERMA* > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Pradeep Kumar Mishra IIIT Allahabad B. Tech 2nd Year ( IT ) [email protected] -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
