Overriding a property ?
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 14 13:39:50 PDT 2016
On 4/14/16 4:21 PM, Lucien wrote:
> How can I override a property ?
>
> Test code:
> ----------------------------
> class A
> {
> @property bool foo { return false; }
This isn't valid, you need parentheses for foo. This doesn't compile
does it?
> void myFunc() { ... }
> }
>
> class B : A
> {
> override bool foo { return true; } // error
Same thing here.
> override void myFunc() { ... }
> }
> ----------------------------
> Output error:
> function B.foo return type inference is not supported if may override
> base class function.
This has to do with type inference. Did you not specify bool in your
original?
If I put parens on both foo, then it compiles for me.
-Steve
More information about the Digitalmars-d-learn
mailing list