Check out example codes for "calling by reference c++". It will help you in understanding the concepts better.

Code Example 1

//call by reference example c++
#include <iostream>

using namespace std;

void swap(int& x, int& y) {
	cout << x << " " << y << endl;
	int temp = x;
	x = y;
	y = temp;
	cout << x << " " << y << endl;

}

int main() {
    
	int a = 7;
	int b = 9;

	swap(a, b);

}

Code Example 2

void fun(int *a)
{
   *a = 10;
}

Code Example 3

void fun3(int a)
{
    a = 10;
}

int main()
{
    int b = 1;
    fun3(b);
    // b  is still 1 now!
    return 0;   
}

Code Example 4

void fun2(int& a) 
{
    a = 5;
}

int main()
{
    int b = 10;
    fun2(b); 

    // now b = 5;
    return 0;
}

Code Example 5

int main() {
    int b = 1;
    fun(&b);
    // now b = 10;
    return 0;
}

Learn ReactJs, React Native from akashmittal.com