fork download
  1. import std.stdio;
  2.  
  3. class S
  4. {
  5. this(int a)
  6. {
  7. this.a = a;
  8. this.increment = { this.a++; };
  9. }
  10. int a;
  11. void delegate() increment;
  12. void oops() const { this.increment(); }
  13. }
  14.  
  15. void main()
  16. {
  17. auto c = new const(S)(0);
  18. writeln(c.a);
  19. c.oops();
  20. writeln(c.a);
  21. }
Success #stdin #stdout 0.02s 2076KB
stdin
Standard input is empty
stdout
0
1