private member

nobody not at possible.de
Fri Apr 13 00:56:14 PDT 2007


Hallo,

import std.stdio;

class Value {
        private int a;
}

void main() {
        Value value = new Value;
        value.a=3;
        writefln(value.a);
}

"a" is a private variable, but i can set it with 
value.a=3;
outside the class.
Is there a way to avoid this.

Under Attributes in the homepage i found this
"Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class."

But value.a=3;  isn't enclosing in a class.

Thanks



More information about the Digitalmars-d-learn mailing list