View Single Post
  #2 (permalink)  
Old May 17th, 2007, 02:18 AM
loginmani loginmani is offline
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi friend,

Look at this below code snippet, it sure help you in understanding the differences :)

void Foo( int * ptr,
          int const * ptrToConst,
          int * const constPtr,
          int const * const constPtrToConst )
{
    *ptr = 0; // OK: modifies the pointee
    ptr = 0; // OK: modifies the pointer

    *ptrToConst = 0; // Error! Cannot modify the pointee
    ptrToConst = 0; // OK: modifies the pointer

    *constPtr = 0; // OK: modifies the pointee
    constPtr = 0; // Error! Cannot modify the pointer

    *constPtrToConst = 0; // Error! Cannot modify the pointee
    constPtrToConst = 0; // Error! Cannot modify the pointer
}

Regards,
S.Manivannan


Reply With Quote