Jan 17, 2009

difference between pointers and reference

difference between pointers and reference
references are aliases to variables ,or you can say other name to a given variable, whereas pointer holds the address of a particular variable.
references have to be initialized at the time of declaration and cannot be changed in the code later , whereas this doesn’t hold true with the pointers.
a pointer is passed by value. The passed pointer can be modified so that it points to a different object, and it can be used to modify a data object that it points to. A reference always refers to the same object. It can be used to modify the object that it refers to, but the reference itself cannot be modified.

No comments:

Post a Comment