Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Tue Jun 25 11:14:33 UTC 2024
On 25/06/2024 3:38 PM, mw wrote:
> Why D choose to be different here? i.e. |shared_AA_class saa = new
> shared_AA_class()| only evaluate only once, and even force it must be
> evaluate-able at compile time?
That has nothing to do with it.
Every type in D has an initialized value, that everything starts off as,
byte for byte.
When you have a field with an initializer it gets put into that
initialized value.
The constructor does not perform the initializer.
More information about the Digitalmars-d-learn
mailing list