Transitive const sucks

Janice Caron caron800 at googlemail.com
Tue Sep 11 11:11:08 PDT 2007


On 9/11/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:

> // tango style
> class NonsenseInD
> {
>   private int _x = 0;
>   int x() const { return _x;}
>   void f() const { x = 5;}
> }
>
> // could be in another file
> int main(char[][] args)
> {
>   const NonsenseInD c = new NonsenseInD;
>   Stdout(c.x).newline; // prints 0;

No it won't, because it won't compile, because x is private.

(It will compile if main is in the same file as class NonsenseInD, but
I can live with that).



More information about the Digitalmars-d mailing list