call by reference in C++ functions code example
Example 1: calling by reference c++
void fun(int *a)
{
*a = 10;
}
Example 2: calling by reference c++
void fun2(int& a)
{
a = 5;
}
int main()
{
int b = 10;
fun2(b);
// now b = 5;
return 0;
}