pinters in c++

Hi……..can any one help plz..
I want to know clear difference between them…

Const int *p
Int const *p
Int * const p=&i
Const int *const p=&j
Int const * const p=&k
Const int arr[]={1,2,3,4};
Void func(cons t int&)
Void func (cons t int *p)
firstly, pointers
secondly, don't capitalize keywords
now,
const int *p a pointer to a constant integer. value of p cand be modified. value of *p, cannot.

int const *p the same

int * const p=&i a constant pointer to an integer i. value of p cannot be modified, but value of *p can.

const int *const p=&j a constant pointer to a constant integer j. neither p nor *p can be changed.

int const * const p=&k the same

const int arr[]={1,2,3,4}; an array of constant integers. no element can be modified

void func(const int&) a function which takes a reference to a constant integer. note: reference itself is basically a constant pointer.

void func (const int *p) a function which takes a pointer to constant integer.
tnx alot hamsterman..........
Note, however, that even though a reference is pretty much a constant pointer, it does not require dereferencing. If you have int& j = i;, you don't need to use *j. You can use j just like a normal variable like i.
Topic archived. No new replies allowed.