This code compiles but doesn't generate the results I'd expect:
char h = 'h';
char& href = h;
std::cout << &href << std::endl;
int x = 1;
int& xref = x;
std::cout << &xref << std::endl;
How do I retrieve the address of the char my char& is aliasing?
The expression is
The problem you are seeing is due to the fact that the type of
std::cout << &href << std::endl
tries to print a null terminated string. You can use
std::cout << (void*)&href << std::endl
to print the address.