reference directly points to value of the memory locationpointers points to the address of the value.
POINTER1) Its not necessary to initialize the pointer at the time of declaration. Likeint a = 10;int *P = &a; //It is not necessary Another way is :int a = 10;int *P;P = &a; 2) You can create the array of Pointer.3) You can assign NULL to the pointer likeint *P = NULL; //Valid4) You can use pointer to pointer.REFERENCE 1) Its necessary to initialize the Reference at the time of declaration. Likeint &a = 10;int &a; //Error here but not in case of Pointer.2) You can not create the Array of reference.3) You can not assign NULL to the reference likeint &a = NULL; //Error4) You can not use reference to reference.
Post a Comment
2 comments:
reference directly points to value of the memory location
pointers points to the address of the value.
POINTER
1) Its not necessary to initialize the pointer at the time of declaration. Like
int a = 10;
int *P = &a; //It is not necessary
Another way is :
int a = 10;
int *P;
P = &a;
2) You can create the array of Pointer.
3) You can assign NULL to the pointer like
int *P = NULL; //Valid
4) You can use pointer to pointer.
REFERENCE
1) Its necessary to initialize the Reference at the time of declaration. Like
int &a = 10;
int &a; //Error here but not in case of Pointer.
2) You can not create the Array of reference.
3) You can not assign NULL to the reference like
int &a = NULL; //Error
4) You can not use reference to reference.
Post a Comment