Gamut
October 29th, 2002, 03:42 PM
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!
PaulWendt
October 29th, 2002, 04:01 PM
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
Gamut
October 29th, 2002, 04:16 PM
Thanks!