Get the address of an object, within the object itself

Andrew Chapman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 15 13:27:00 PST 2017


Hi all, sorry if this question is silly, but is it possible to 
get the address of an object within the object itself?

e.g.

class Node
{
     this()
     {
         writeln(&this);  // Doesn't work
     }
}

auto node = new Node();
writeln(&node); // Does work

Thanks very much,
Cheers,
Andrew.


More information about the Digitalmars-d-learn mailing list