How to override impure function from pure function
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 12 21:10:02 PST 2016
On Tuesday, 13 December 2016 at 04:48:11 UTC, Nikhil Jacob wrote:
> In the D spec for pure functions it says that a pure function
> can override
>
> "can override an impure function, but an impure function cannot
> override a pure one"
>
> Can anyone help me how to do this ?
what this means is
class Foo
{
void foo() { ... }
}
class Bar : Foo
{
override void foo() pure { ... }
}
is allowed. but
int someglobal;
class Foo
{
void foo() pure { ... }
}
class Bar : Foo
{
override void foo() { someglobal = 42; }
}
in not.
More information about the Digitalmars-d-learn
mailing list