Default value for member class
Adam D. Ruppe
destructionator at gmail.com
Mon Feb 10 18:32:42 UTC 2020
On Monday, 10 February 2020 at 18:18:16 UTC, JN wrote:
> Is this expected?
Yes, it is per the spec, though new users find it weird. Maybe we
should change this but any static initializer is run at CTFE.
Then the *static pointer* is put into the static initializer,
which is just copied over before the constructor.
So it ends up being an instance reference to a static object.
If you want a new one, call `new Foo` in a regular constructor.
More information about the Digitalmars-d-learn
mailing list