March 30, 2003 Fields problem | ||||
---|---|---|---|---|
| ||||
According to <http://www.digitalmars.com/d/class.html> (example class Abc, about 60 lines down from top) the following code should be legal, but it doesn't compile: // setget.d class Test { int x; } class Test2 { int xx; void x(int x) { xx=x; } // set'er int x() { return xx; } // get'er } int main(char [][] args) { int i; Test t=new Test; t.x=5; i=t.x; Test2 t2=new Test2; t2.x=5; // setget.d(19): cannot implicitly convert int to void(int x) i=t2.x; // setget.d(20): cannot implicitly convert void delegate(int x) to int return 0; } //end of setget.d Why? -- Helmut Leitner leitner@hls.via.at Graz, Austria www.hls-software.com |
March 31, 2003 Re: Fields problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Helmut Leitner | If you'll take a look at http://www.digitalmars.com/d/alpha.html you'll notice at the bottom it states: Property gettor/settor not implemented. "Helmut Leitner" <helmut.leitner@chello.at> wrote in message news:3E8767E9.48F4AF91@chello.at... > According to > <http://www.digitalmars.com/d/class.html> > (example class Abc, about 60 lines down from top) > the following code should be legal, but it doesn't compile: > > // setget.d > class Test { > int x; > } > > class Test2 { > int xx; > void x(int x) { xx=x; } // set'er > int x() { return xx; } // get'er > } > > int main(char [][] args) { > int i; > > Test t=new Test; > t.x=5; > i=t.x; > > Test2 t2=new Test2; > t2.x=5; // setget.d(19): cannot implicitly convert int to void(int x) > i=t2.x; // setget.d(20): cannot implicitly convert void delegate(int x) to int > > return 0; > } > file://end of setget.d > > Why? > > -- > Helmut Leitner leitner@hls.via.at > Graz, Austria www.hls-software.com |
Copyright © 1999-2021 by the D Language Foundation