Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 23, 2003 Implicit conversion of properties | ||||
---|---|---|---|---|
| ||||
Shouldn't it be possible to use properties as the type they represent without casting? I had a property foo of type float which I tried to return in some other function. float bar() { return foo; } For this to work I must cast foo to float: return (float)foo; Lars Ivar Igesund |
September 23, 2003 Re: Implicit conversion of properties | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | More problems: In the subclass to where the property foo is declared; I'm not allowed to do any of these: super.foo = value; // foo and value are floats this.foo = value; foo = value; There first returns this error: 'super.foo()' is not an lvalue The other to this: 'this.foo()' is not an lvalue (Shouldn't it be 'a lvalue', not 'an lvalue'?) Lars Ivar Igesund |
September 24, 2003 Re: Implicit conversion of properties | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "Lars Ivar Igesund" <larsivi@stud.ntnu.no> wrote in message news:bkp1pc$2gmn$1@digitaldaemon.com... > Shouldn't it be possible to use properties > as the type they represent without casting? > > I had a property foo of type float which > I tried to return in some other function. > > float bar() > { > return foo; > } > > For this to work I must cast foo to float: > > return (float)foo; Can you make a complete source snipped illustrating this? How is foo defined? |
September 24, 2003 Re: Implicit conversion of properties | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:bkr2gi$29sc$2@digitaldaemon.com... > > Can you make a complete source snipped illustrating this? How is foo defined? This don't compile with 0.73 until return foo; is changed to return (float)foo; in the subclass. The set method works without casting. In my other post I said that setting like this don't work, but that only seems to be the case when i qualify foo with this or super. class bar { public: float foo() { return bar; } float foo(float value) { return bar = value; } private: float bar; } class subbar : bar { public: float subfoo() { return foo; } float subfoo(float value) { return foo = value; } } Lars Ivar Igesund |
Copyright © 1999-2021 by the D Language Foundation