In below code snippet , while using & with reference variable , we are getting the address of the variable to which the reference variable points but during a function call , the reference variable would have been allocated on the stack frame , so how to get that address value ?
#include <iostream>
using namespace std;
void modify(int& x)
{
x=9;
cout<<&x<<endl<<x<<endl;
}
int main() {
int a=8;
modify(a);
cout<<&a<<endl<<a;
return 0;
}
Here both &x and &a print same value , which is the address of the variable a , so is there any way by which we can get the address of the reference variable x ?