Passing pointers/references to a function for efficiency confusion.

I understand that passing an object to a function by pointer would be efficient, because you're just sending over an address using "&" instead of the whole object.

But I don't see how passing over an object by reference is efficient, because you're still sending over the object.
It's because there is no overhead of copying when you pass it by reference.
So when you send something to a function, the actual object is sent to the function and then it's decided rather to make a copy or not?
By default every thing is passed by value to functions. That means the copy of the variable will be made. However, when you pass by reference then actual variable is sent. Hence, no copy.
Topic archived. No new replies allowed.