D - Implicit conversion of properties
- Lars Ivar Igesund (11/11) Sep 23 2003 Shouldn't it be possible to use properties
- Lars Ivar Igesund (12/12) Sep 23 2003 More problems:
- Walter (4/14) Sep 23 2003 Can you make a complete source snipped illustrating this? How is foo
- Lars Ivar Igesund (32/34) Sep 24 2003 This don't compile with 0.73 until
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
Sep 23 2003
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
Sep 23 2003
"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?
Sep 23 2003
"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
Sep 24 2003