Pointers and Reference looks similar but there are some difference between both of them.
- Its not necessary to initialize the pointer at the time of declaration. Like
int a = 10; int *P = &a; //It is not necessary
int a = 10; int *P; P = &a;
- You can create the array of Pointer.
- You can assign NULL to the pointer like
int *P = NULL; //Valid
- You can use pointer to pointer.
- 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.
- You can not create the Array of reference.
- You can not assign NULL to the reference like
int &a = NULL; //Error
- You can not use reference to reference.
leila like this