Monday, July 23, 2012

What is the difference between a Reference and a Pointer?


1. References cannot be null, whereas pointers can;
2. References must be initialized as soon as they are created. On the contrary, it is not mandatory for pointers.
3. A pointer must be manually freed whereas a reference gets automatically dereferenced.
4. You can create the array of Pointer; but you can't create the Array of reference.
5. A pointer can point to many different objects during its lifetime; but a reference can only object during its lifetime.
6. You can declare a constant pointer; but you can't declare a constant reference though it is inherently constant.


No comments :