Get address of object in constructor.

WebFreak001 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 13 08:49:20 PDT 2016


On Sunday, 13 March 2016 at 15:43:02 UTC, MGW wrote:
> I want to get address of object Cfoo in constructor. Whether it 
> is possible?

class Cfoo {
	void* adrThis;
	this() {
		adrThis = cast(void*) this;
	}
}
...
Cfoo foo = new Cfoo();

"this" should work

(pun intended)


More information about the Digitalmars-d-learn mailing list