Possible Duplicate:
Pass by Reference / Value in C++
I was wondering what the difference is between a call by value/reference/name. And why would it be beneficial to use one over another?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
call by value: a copy of the parameters is passed to the function
call be reference: no extra copy is made, the caller’s variable is passed directly.
Major difference is that one extra unnecessary copy is made in call by value paradigm… You should always use call be reference (or const reference) unless a callee needs to modify the variable and you don’t want the changes to your caller’s variable…