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


