What exactly does “pass by reference” mean?

后端 未结 8 2117
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 03:15

And who has the authority to decide?

Edit: Apparently I haven\'t succeeded in formulating my question well.
I am not asking how Java\'s

8条回答
  •  伪装坚强ぢ
    2020-12-30 04:08

    Wikipedia gives a very clear definition of call-by-reference I can not improve upon:

    In call-by-reference evaluation (also referred to as pass-by-reference), a function receives an implicit reference to a variable used as argument, rather than a copy of its value. This typically means that the function can modify (i.e. assign to) the variable used as argument- something that will be seen by its caller.

    Note that neither of your examples is call-by-reference, because assigning a formal parameter in C never modifies the argument as seen by the caller.

    But that's enough copy-pasting, read the thorough discussion (with examples) at

    http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_reference

提交回复
热议问题