mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
25 lines
335 B
D
25 lines
335 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/fail223.d(14): Error: cannot modify `this.x` in `const` function
|
|
---
|
|
*/
|
|
|
|
//import std.stdio;
|
|
|
|
class A
|
|
{
|
|
public:
|
|
int x = 0;
|
|
void setX(int nx) const { x = nx; }
|
|
}
|
|
|
|
void foo(const A a) { a.setX(1); }
|
|
|
|
int main(char[][] args)
|
|
{
|
|
A a = new A;
|
|
foo(a);
|
|
//writefln(a.x);
|
|
return 0;
|
|
}
|