C++/call by refrence
i have a question about calling variables in functions
could you plz tell me what's the diffrence between:
power(&a) and power(*a)
i know that in power(&a) the address of 'a' will be change but will the value of 'a' change too?
or in power(*a) the value of a will change but will the address of it change too?
i mean the main values and addresses,not the values or addresses that we use in function power
I am not sure what you mean.
If you mean int power ( int & a ) and int power ( int * a ) then to call the first one you use something like power ( b ) where b is an int and you use power ( & b ) where b is an int or power ( c ) where c is a int * c or pointer to an int, in the second case.
In the case of power ( b ), if the argument variable ( a ) is changed in power then b will be changed.
In the case of power ( & b ) if the address the pointer is pointing to is changed then b is changed. In other words changing *a changes b. In the case of power ( c ) if *a is changed then *c is changed. Changing the pointer in power ( or a ) has no affect on b at all.