CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    145

    Question pointer delcaration

    can someone explain the difference between the foll declarations?

    1. const T *pEle;
    2. T * const pEle ;
    3. const T * const pEle;

    Thnx in Advance!

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347

    Re: pointer delcaration

    Originally posted by Gamut
    can someone explain the difference between the foll declarations?

    1. const T *pEle;
    2. T * const pEle ;
    3. const T * const pEle;

    Thnx in Advance!
    1) This is a pointer to const. So, you cannot modify the object
    you are pointing to through this pointer. You can make the
    pointer point to another item, however.

    2) This is a constant pointer to non-const data. You can modify
    the data you're pointing at, but you cannot point to another item.

    3) This is a constant pointer to const data. You can modify
    neither the data you're pointing to nor the pointer itself.

    --Paul

  3. #3
    Join Date
    Jun 2001
    Posts
    145
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured