Call by reference in C++
c++, pass-by-reference, reference
Solution
What's actually passed to the function is a reference. The named parameter `b` becomes a synonym for the argument object `q`.
How the compiler probably implements this that the caller places the address of `q` on the stack or in a register before calling, and the callee uses that value to effect all accesses to `b`. But it could be misleading to describe that as "actually passing" a pointer, because parameter passing is a concept at the level of the C++ language, and at that level it is not the same concept as passing a pointer. For instance, when you pass a pointer you can pass a null pointer, but when you pass a reference you cannot (validly). So it'd be wrong to say they're same thing.
That said, the person implementing the compiler might describe it as "actually passing a pointer", and you know what they mean. For comparison, if `char` variables occupy 4-byte stack slots in the calling convention, they might say that the compiler is "actually passing an int". So it depends what "actually" is supposed to mean.
Problem
What is actually passed in call by reference to a function? ``` void foo(int &a,int &b) ``` when I write ``` foo(p,q) ``` what is actually passed to the function. Is it the address of p and q?