The Final(ize) Challenge
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon May 18 15:41:16 PDT 2009
Frits van Bommel wrote:
> 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;
> }
Damn. I meant to NOT inherit from A.
Andrei
More information about the Digitalmars-d
mailing list