const int *
-
what is meaning of const int * & int * const.
-
what is meaning of const int * & int * const.
The difference is where the
const
applied; is it applied to the pointer, or what is being pointed to. The first one is a pointer to aconst int
, meaning that the pointer can change (you can have the pointer point to a differentint
), but not what is pointed to. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
what is meaning of const int * & int * const.
-
what is meaning of const int * & int * const.
i Think u r not clear from above two ans so i m explaing u ... Pointer To Const syntex: int const *ptr; or const int *ptr; that means they are pointer to const int. so we can't change the value of they are pointing. we can change what they r pointing.... for example: int i = 10; int b = 20; int const *ptr = & i; (*ptr)++ ; // will give error ptr = & b ; // OK Const pointer: syntex : int * const ptr1; it is const pointer so what it is pointing is const so we must initialize at the time of declaration so synetx is like int * const ptr1 = & someintegervarible; for example: int i = 10; int b = 20; int * const ptr1 = & i; //required initialization (*ptr1)++ ;//OK ptr1 = & b; // Error we also have const pointer to const : syntex : int const * const ptr2 = & i; // required initialization or const int * const ptr2 = & i; // required initialization Neither address which that pointer is pointing nor the value that pointer pointing will change. Hiren Thakkar