What does this mean " bool function1(int * & a) "
is it that address of a is a pointer to the integer that will be inputed in the function1 call? and why would this be used in general?
thank you
#include <iostream>
void fa(int i)
{
i = 99; // i is a local copy
}
void fb(int &i)
{
i = 99; // i is a reference
}
int main()
{
int number = 1;
fa(number);
std::clog << "after fa(): " << number << '\n';
fb(number);
std::clog<< "after fb(): " << number << '\n';
}
In your case, you pass a pointer by reference. The effect is the same as in the number example. The value of the pointer (a memory address: a number) can be changed in the function and the changes will be visible outside the function.
The confusion is because & is also used as the address-of operator, which gets the address of something.