Overriding a property ?

Satoshi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 14 13:36:01 PDT 2016


On Thursday, 14 April 2016 at 20:21:38 UTC, Lucien wrote:
> How can I override a property ?
>
> Test code:
> ----------------------------
> class A
> {
>     @property bool foo { return false; }
>     void myFunc() { ... }
> }
>
> class B : A
> {
>     override bool foo { return true; } // error
>     override void myFunc() { ... }
> }
> ----------------------------
> Output error:
> function B.foo return type inference is not supported if may 
> override base class function.
>
> Any ideas ?


try

class A
{
     @property bool foo() { return false; }
     void myFunc() { ... }
}

class B : A
{
     override @property bool foo() { return true; } // error
     override void myFunc() { ... }
}



More information about the Digitalmars-d-learn mailing list