private attribute don't function?
David Nadlinger
code at klickverbot.at
Sat Oct 5 08:21:44 PDT 2013
On Saturday, 5 October 2013 at 15:19:34 UTC, Zhouxuan wrote:
> import std.stdio;
>
> class A
> {
> private int j = 1;
>
> private
> {
> int k = 2;
> }
>
> private:
> int i = 0;
> }
>
> void main()
> {
> A a = new A;
> writeln(a.i);
> writeln(a.j);
> writeln(a.k);
> }
In D, "private" means "private to the current module". If you try
accessing the fields from another module, you'll see that it
doesn't work.
In the future, please consider posting similar question in
digitalmars.D.learn.
David
More information about the Digitalmars-d
mailing list