The difference between passing by value and passing by reference is that unlike passing by values, when we are passing by reference, the address of the declared in one function gets passed to another.
void func(int& a){
a *= 4;
return;
}
int main(){
int n = 3;
func(n);
std::cout << n << std::endl; //displays 12
}
In this case, n will be created and stored in the stack right? When we pass by reference, does the address pointing to n in the stack be passed to func? If so, how is it possible to access a variable from a different stack frame?