cast(public)

Sönke Ludwig ludwig_nospam at informatik.uni-luebeck.de
Sat Jul 18 02:36:52 PDT 2009


Robert Clipsham schrieb:
> dsimcha wrote:
>> struct Foo {
>>     private uint bar;
>> }
>>
>> void main() {
>>     Foo foo;
>>     foo.bar++;  // error
>>     (cast(public) foo.bar)++;  // Works.
>> }
> 
> ----
> struct Foo {
>    private uint bar;
> }
> 
> void main() {
>    Foo foo;
>    foo.bar++;  // This works for me with dmd 1.026,
>                // dmd 2.031 and ldc r1411
>    // foo.bar is now 1.
> }
> ----
> 
> Same effect for classes... Am I missing something or is this a bug?

Protection attributes will be ignored inside of the same module. This is 
by design to have an alternative for C++ friend declarations.



More information about the Digitalmars-d mailing list