How to break const

Mehrdad wfunction at hotmail.com
Mon Jun 18 00:14:59 PDT 2012


Okay, how about this? http://ideone.com/VMlzS

Does this break const?


import std.stdio;
class S
{
         this(int a)
         {
                 this.a = a;
                 this.increment = { this.a++; };
         }
         int a;
         void delegate() increment;
         void oops() const { this.increment(); }
}
void main()
{
         auto c = new const(S)(0);
         writeln(c.a);
         c.oops();
         writeln(c.a);
}


More information about the Digitalmars-d mailing list