hello guys,
I want to know the difference between pointer and reference. Are these similar or not. Please explain me.
thanks.
PUNJABIAN263
***GREAT PEOPLE HAVE GREAT PUPIL***
Printable View
hello guys,
I want to know the difference between pointer and reference. Are these similar or not. Please explain me.
thanks.
PUNJABIAN263
***GREAT PEOPLE HAVE GREAT PUPIL***
Pointer and reference are similar in some ways while they are really different. It's really not easy to explain the difference but I will see if I can clarify for you.
Pointers can be used to create link lists, stacks etc but reference can't. You can de-reference a pointer. Well reference is an address whilst a pointer points to an address. So I guess what am trying to say is that a pointer can be treated as a reference but a reference can't be treated like a pointer.
I hope that helps.
Guidance...
read this tut if you want to learn how pointers work: http://www.antionline.com/showthread...hreadid=247055
I guess cutty said it best when you talk about a reference you're talking about an specific space in memory where something is, the adress to it. Whereas a pointer is something that points to somewhere in memory, you usually assign this refrences to pinters. I recommend you reading about pointers for they are a little bit tricky at first but a very useful tool later on when dealing with dynamic memory specially.
http://www.codeproject.com/cpp/pointers.asp