Home>

I don't know the principle of pointer passing by reference, so I would appreciate it.

====================================
[When passing a normal variable]
void main () {
int a = 10;
hoge (a);
}

void hoge (int&a) {
std :: cout<<a<<std :: endl;
}

====================================

====================================
[When passing a pointer]
void main () {
int b = 10;
int * a =&b;
hoge (* a);
}

void hoge (int&a) {
std :: cout<<a<<std :: endl;
}

====================================

In the case of the first [Normal], it can be done with hoge (a),
In the case of a pointer, I am not sure where the pointer is passed to the function.
When [Normal] is passing a real value, why would you pass that pointer when referring to [Pointer]?