Tuesday, December 10, 2013

C/C++ Pointers vs References

a pointer can point to many different objects during its lifetime, a reference can refer to only one object during its lifetime

References are the preferred way of indirectly accessing a variable. They are also a little
safer than pointers and, in some cases, are the only way to achieve a particular result such
as overloading certain operators.

the address can directly be manipulated if it is a pointer.A pointer can be incremented to point to next address.This is not possble with references.

References
http://www.dgp.toronto.edu/~patrick/csc418/wi2004/notes/PointersVsRef.pdf

No comments:

Post a Comment