Call by Value and Call by Reference in C++

Call by Reference in C++, it permits us to pass parameters to the function by reference. When we pass the arguments by reference, the formal arguments in the called function becomes aliases to the actual arguments in the calling function that means when the function is working with its own arguments.

void swap(int *a, int *b)
{
 int n;
n=*a;           // assign the value at the address a to n //
*a=*b;
*b=n;
}
swap(&x, &y);   // call by passing //

Recommended Posts:

C++
    1. Concepts of OOP
    2. C++ input output functions
    3. Data Types in C++
    4. Operators in C++
    5. C++ Control Statements | if-else, switch, for, while and do-while
    6. Call by Value and Call by Reference in C++
    7. Inline Function in C++
    8. Default Arguments in C++
    9. Function Overloading in C++
    10. C++ Program to Find Factorial of Number
    11. C++ Program to Solve Tower of Hanoi using Recursion