Quote (postmortemvox @ May 8 2015 01:02pm)
That's pretty shallow considering that he expanded answers that were technically correct but incomplete in this context. If the OP doesn't know the difference between passing by value vs passing by reference, do you really think that saying "& gets the memory address of the variable" is going to tell him everything he needs to know? And while the link posted is conceptually almost identical (setting aside possibility of null pointers, etc), it still referred to passing pointers rather than passing arguments by reference, which can be confusing to someone learning this stuff.
If you're still confused, there are a lot of tutorials that will break down the differences. Here's the first that popped up on a google search, which seems to have a number of visual aids if that helps you understand:
http://www.youtube.com/watch?v=TgsH02sORZ0Yeah I didn't want to get technical, I just wanted to say what it does, not how it works.
/e And it's worth noting that using & has better performance on classes with multiple member variables, because instead of copying every variable you are just copying one memory address. If you know you aren't going to make any changes to an object's members then you can use & to pass by reference, but it's also good habit to use "const" as well just to make sure you aren't making any changes, like:
int DoSomething(const &object) { ... }
This post was edited by Mastersam93 on May 8 2015 08:28pm