www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - visibility deprecation with last dmd compiler

reply jacob <jj75607 gmail.com> writes:
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
parent Adam D. Ruppe <destructionator gmail.com> writes:
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.
May 03 2017