Why does passing by reference work?

In a C++ book I'm reading it is teaching how passing variables into a function by reference will change their value in main, instead of only in the function. I understand that passing the variables into the function as a reference will do the trick, but why does it?

I'm having a hard time understanding why it works. Can anyone please explain it to me?
Thank of it like this. If you were to take a piece of paper and write (with pencil) anything you wanted on it.

Passing by reference would pass that peice of paper into the function and actually change it. Rather than passing a (copy)(non reference) into the function.

So you would pass by refereence if you want to change the value etc. or you would pass by reference sometimes for speed reasons so you dont have to make a copy of the datatype which is a lot slower. just imagine if you had a piece of paper that you wrote an essay on and that you had to copy it only to destroy it after you used it for what you needed.

I hope I helped explain it. But I think techniquley when you pass by reference you pass the function a memory location of the object in order to goto that object and change values etc.

Im sure someone will come in here and give better advice. For the meantime though I hope it helped
That was actually really nice advice. After doing more research I've found that pass by value is specifically used so the function does not change the original value, by creating a copy of the variable; something I didn't understand. Thanks for your help, it was greatly needed.
Topic archived. No new replies allowed.