Transitive const sucks

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Sep 11 13:54:04 PDT 2007


Janice Caron wrote:
> On 9/11/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>> What is the argument against mutable again?
> 
> In C++, you can do this:
> 
>  class C
>  {
>  public:
>      mutable int x;
>      C() { x = 0; }
>      void f() const { x = 5; }
>  }
> 
>  main()
>  {
>      const C c;
>      printf("%d\n", c.x); /* prints 0; */
>      c.f();
>      printf("%d\n", c.x); /* prints 5; */
>  }
> 
> This is clearly nonsense.
> 
> That would be disallowed in my scheme. (...at least, if main() was in
> a different file from the definition of C).

And why is this nonsense?? Because x is public? I don't see the problem 
here.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list