Call by reference in C++

Call by reference method of passing arguments to a function that the address of an argument into the formal parameter.

Source code :


#include <iostream>

using namespace std;

int myFunc(int *,int *);


int main()
{
	int a=10,b=75;
	myFunc(&a,&b);
	return 0;
}

int myFunc(int *a,int *b)
{
	cout << "The sum is " << (*a +*b);
	return 0;
}


Output :

The sum is 85

Output :


                

Comments :