pass by value and pass by reference

i think i understand both concept. i know that pass by value is that the function receiving those values makes actually a copy of those parameters. Passing by reference makes the variable in the main function to actually see those changes in the other function, instead of a copy, and apply them to the variable in the main function. my question is, why would i pass it by reference if i just can make a return type function. thanks.
when you pass by reference you are sending the address of the variable to the function. When you pass by value you are making a copy of the object on the stack. if the object is large, it takes more then a few cycles to copy the object and delete it from the stack. the same is true when you want to return a type by value. The CPU creates a copy of the return value on the stack, then uses this to set the variable from which you are using. General rule of thumb is never return local variables by reference or by pointer, and always pass by reference if its not a Predefined type. If you don't want the function to be able to change the values of the object, pass by const reference.

void ConstRef(const myClass& Class)  //makes class not modifiable, but still accessible
so it's actually more comfortable to pass by reference than by value?
say you want a function that will multiply a number by two and add three, and you want the function to actually change the value in your variable, you would pass by reference.
Usually comfy, except for predefined types. A reference to a char is probably bigger than a char.

There are functions that do need to return more than one value. That is easier with references.
thanks to everyone. i understand better now
Topic archived. No new replies allowed.