On Wednesday, 22 November 2017 at 15:17:33 UTC, Adam D. Ruppe wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch wrote:
&this will do.

Even if it were an lvalue, that would be the address of a local. You should basically NEVER do that with D classes.

Just `cast(void*) this` if you must pass it to such a function.

It's worth noting that you will still be passing different addresses to foo(void*) because classes are reference types in D (structs are not). In the constructor you're passing the address of the class object itself, but in the main function you're passing the address of the reference.

Reply via email to