does the answer still remain same if you do the following: const int d=1; const int *const ptr = &d;
In your version I don't see ptr pointing to a const int. It just points to an integer, which I think can be changed. See if the code I suggested still does the same as your version... On 8 August 2011 19:53, 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. > -- ___________________________________________________________________________________________________________ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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.
