call-by-reference love

call-by-reference

Definitions

from Wiktionary, Creative Commons Attribution/Share-Alike License

  • n. An evaluation strategy in which the arguments to a function are evaluated first, and a pointer to the result is passed to the function.

Etymologies

Sorry, no etymologies found.

Examples

  • In call-by-value, argument value is not altered in calling program but if passed using call-by-reference then changes done to the value of argument in the called function also gets reflected in the calling function.

    LearnHub Activities

  • In call-by-reference using pointers, we have dereferencing operator (*) in-between data-type and variable name.

    LearnHub Activities

  • Call-by-reference using reference variable has neatier code than inside function using call-by-reference using pointers.

    LearnHub Activities

  • However, if call-by-reference using pointers is used then you will have (&) in-between data-type and variable name in the calling program.

    LearnHub Activities

  • Now, you must be wondering how to decide when to use call-by-reference using pointer and when to use call-by-reference using reference variable.

    LearnHub Activities

  • In call-by-reference using reference variable, we have address-of (&) operator in-between data-type and variable name.

    LearnHub Activities

  • Now, question is when to use call-by-reference using pointer variable and when by reference variable.

    LearnHub Activities

Comments

Log in or sign up to get involved in the conversation. It's quick and easy.