What is the difference between call by value and call by reference in c++ ????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomjakson
    New Member
    • Aug 2014
    • 2

    What is the difference between call by value and call by reference in c++ ????

    call by value and call by reference is used in functions to pass the arguments.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Are you asking what the terms call by value and call by reference mean? (They mean pretty much the same thing for all languages.)
    Or do you understand the terms, but want to know how to tell C++ to use one technique or the other?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Call by value means that the value is copied on the call. The called function operates on the copy. All calls in C are call by value.

      Call by reference means the value is not copied on the call. The function operates on the original value. The function argument is a reference argument making the name of the value in the function call an alias for the original value. C++ can use call by reference by using reference arguments in the function.

      Comment

      Working...