Next Generation Emulation banner

Difference between reference and pointers.

1343 Views 6 Replies 5 Participants Last post by  Syed Fawad
I tried to search the web but I am kinda having difficulty in finding some "basic" difference between these two in layman terms.


int A;
int *pA;
pA = &A;


int A;
int &rA = A;

So what?

A is the name of the address of 2 bytes reserved in memory for integer type.
pA is the pointer which contains the address of A.
So what would rA be?
1 - 3 of 7 Posts
klatch said:
In C++, references are implicit pointers. Basically, when passing a reference, the receiving function has only a copy of the value in the address passed. The value in the original function cannot be manipulated by anything but its originating function. So it's like a "safer" but less versatile pointer. If you want a detailed read on when to use which, try this.

In C, there are only pointers.

In Java, there are only references.
You said that passing through referance leaves the called function with only a copy of the value stored at the addressed referred.

Is it not the same same as passing the value?

I mean:

void myfunc(int &I)
I = I +1;

void main(void)
int A=2;

What'll happen? vbmenu_register("postmenu_836894", true);
See less See more
Exo cleared up the things I had in my mind after some more searches on google ...and then he went deeper then my light can reach :)
Thanks a lot buddy!

Keith, I have seriously no idea what caused that. I just completed my type and pressed the post button like I have done some thousand times :p
But this is the first time that sprang up....something to do with me posting after a LONG time?

Moreoever, I'd assume that this thread has fulfilled its purpose .... and I have copy pasted Exo's post for any reference needed later so any one may close up this thread. If someone would like to tell me more stuff related to this topic then a very thankfully welcomed PM may be used.

Over 'n out,
1 - 3 of 7 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.