Hi……..can any one help plz..
I want to know clear difference between them….(plz explain with example in every case)
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)
Plz xplain in detail with example…I ‘ll be very thankful to u
no difference (just written differently) -> a pointer to a constant int. The pointer can be modified (new assigned). The value cannot be modified
int * const p=&i a constant pointer to a variable int. The pointer is initialize with the pointer to i. The pointer cannot be modified
constint *const p=&j a constant pointer to a constant int. The pointer is initialize with the pointer to j. The pointer and the value cannot be modified
constint arr[]={1,2,3,4}; an array of constants int.
void func(constint&) a function that takes a constant int as a reference.
1 2
int x = 0;
func(x);
references are similar to pointer except that you don't have to derefence it when assigning a value.
1 2 3 4 5
int x = 0;
int &y = x; // y refenrences x
y = 1; // means x = 1
int *z = &x; // z points to x
(*z) = 1; // means x = 1 -> (*z) is derefenrence
void func (constint *p) a function that takes a pointer (of int)