Unintentional sharing?
H. S. Teoh
hsteoh at qfbox.info
Thu Jun 6 20:50:41 UTC 2024
On Thu, Jun 06, 2024 at 05:49:39PM +0000, Andy Valencia via Digitalmars-d-learn wrote:
> I was using instance initialization which allocated a new object. My
> intention was this initialization would happen per-instance, but all
> instances appear to share the same sub-object? That is, f1.b and f2.b
> appear to point to a single object?
[...]
Yes, if you want a per-instance object, you need to do it in this(), not
in the initializer.
--T
More information about the Digitalmars-d-learn
mailing list