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