May 03, 2017 visibility deprecation with last dmd compiler | ||||
---|---|---|---|---|
| ||||
I have 2 files file abc.d: == module my.abc; class Abc { private int x; this() { this.x = 1; } } == and xyz.d: == module my.xyz; import my.abc; class Xyz: Abc { this() { super(); this.x = 2; } } == Compilation fails with "Deprecation: my.abc.Abc.x is not visible from module xyz" As I understand, the reason is https://dlang.org/changelog/2.071.0.html#dip22 But how can I use private fields from descedant class? |
May 03, 2017 Re: visibility deprecation with last dmd compiler | ||||
---|---|---|---|---|
| ||||
Posted in reply to jacob | On Wednesday, 3 May 2017 at 14:14:16 UTC, jacob wrote:
> But how can I use private fields from descedant class?
You don't, the whole point of private is that they aren't used from outside the module.
Try `protected` instead, it is similar to private, but still allows use from a subclass.
|
Copyright © 1999-2021 by the D Language Foundation