The Final(ize) Challenge
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Mon May 18 15:01:17 PDT 2009
Andrei Alexandrescu wrote:
> Good point! Now define Unfinalize that opens the final methods of a
> class for method overriding.
>
> class A
> {
> final int foo(string) { ... }
> }
>
> class UnfinalizeA : A
> {
> int foo(string a) { return super.foo(a); }
> }
DMD rightly doesn't allow this:
---
test.d(8): Error: function test.UnfinalizeA.foo cannot override final function
test.A.foo
---
There's a workaround though:
---
class UnfinalizeA : A
{
int foo_(string a) { return super.foo(a); }
alias foo_ foo;
}
---
More information about the Digitalmars-d
mailing list