1 /* 2 TEST_OUTPUT: 3 --- 4 fail_compilation/fail223.d(14): Error: cannot modify this.x in const function 5 --- 6 */ 7 8 //import std.stdio; 9 10 class A 11 { 12 public: 13 int x = 0; setX(int nx)14 void setX(int nx) const { x = nx; } 15 } 16 foo(const A a)17void foo(const A a) { a.setX(1); } 18 main(char[][]args)19int main(char[][] args) 20 { 21 A a = new A; 22 foo(a); 23 //writefln(a.x); 24 return 0; 25 } 26