encapsulation
David B. Held
dheld at codelogicconsulting.com
Thu Mar 22 00:35:39 PDT 2007
arun s wrote:
> class A {
> private int c=0;
> }
>
>
> void main() {
> A a = new A();
> printf("%d",a.c);
> }
>
> consider the above code snippet..... y there is no error in printf statement
> a.c , since attribute "c" is private ????
In D, 'private' really means 'package private', like Java's 'package'
visibility (or 'default' visibility), not like C++'s 'private'. While I
prefer tight visibility semantics, I think this is a reasonable compromise.
Dave
More information about the Digitalmars-d
mailing list