How to get the address of an instance of a class

dokutoku 3729541-dokutoku at users.noreply.gitlab.com
Wed Sep 25 17:32:25 UTC 2019


I wrote the following code to get the address of a class 
instance, but it doesn't work.
Please let me know if there is a way to write it to work properly.

private import std;

```
class C
{
	C* this_pointer()
	{
		return this;
	}
}

void main()
{
	C Z = new C();
	writeln(&Z == Z.this_pointer());
}
```



More information about the Digitalmars-d-learn mailing list