Oops there is missing declaration of the variable a
. This is what you should be examining:
class A {};
int main() {
A a;
std::cout << &(A() = a) << "\n";
}
@wallhackio OK, if the a
is declared, then I think that A()
is creating a new object of class A
, and then = a
copies the values from a
into it, and, like any assignment, returns its right part, so returns a
, and &
will simply return the address of a
.
But I'm too stupid for C++, I'm probably wrong
@vaporeon_ @wallhackio this is very close but there is some pedantry here
&
) out of the result of the expurression. (no i do not even know how to begin to explain what an lvalue refurence “is”)
@vaporeon_ @aescling but the result of
A()
is an rvalue, which is not allowed to be given to & or appear on the left side of an assignment. That is the mystifying part here