got it.. thanks guys On Mon, Aug 8, 2011 at 8:00 PM, mohit verma <mohit89m...@gmail.com> wrote:
> No .. in this case it flags error. > > > On Mon, Aug 8, 2011 at 7:58 PM, Dipankar Patro <dip10c...@gmail.com>wrote: > >> 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 <mohit89m...@gmail.com> 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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > ........................ > *MOHIT VERMA* > > -- ........................ *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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.