Can I make a variable public and readonly (outside where was declared) at same time?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 26 10:52:57 PDT 2014


Marc Schütz:

> Alternatively, you could create a union with a private and a 
> public member with the same types, but I wouldn't recommend it. 
> Besides, the members would need to have different names:
>
>     class Foo {
>         union {
>             private int a;
>             public int b;
>         }
>     }

You can call them a and a_. Why are you not recommending this 
solution? It looks cool (if it works).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list