Pass by Value vs Pass by Reference

Sikander Shaikh
1 min readMay 19, 2020

Pass by Value means the called function’s parameter will be a copy of the caller’s passed argument. When parameter is passed to a function, it’s fully evaluated and a new copy of the value (result) is made in function’s scope.

Pass by Reference means the called function’s parameter will be the same as the caller’s passed argument (not the value, but the identity — the variable itself). When parameter is passed to a function, only the reference of the variable is passed.

Advantages of Pass by Reference:

  1. It is fast, as there is no copy of the argument is made.
  2. To avoid changes done unintentionally we can even make it pass by const reference.
  3. We can return multiple values from a function.

Thanks..!!

>> Follow me on GitHub & Instagram

>> Visit my site : www.imsikander.com

@iSikanderShaikh

--

--

Sikander Shaikh

Software Engineer | Artist | Epigrammatist | Philosopher