how to fix such a hijacking problem in D ?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Dec 18 05:36:57 PST 2007


"z_axis" <z_axis at 163.com> wrote in message news:op.t3i7wpdc1uofcn at sw2wolf...
> thanks for all your answer !
> i really donot understand the following sentences from 
> http://www.digitalmars.com/d/hijack.html
>
> The D solution is straightforward. If a function in a derived class 
> overrides a function in a base class, it must
> use the storage class override. If it overrides without using the override 
> storage class it's an error.
> If it uses the override storage class without overriding anything, it's an 
> error.
>
> regards!

It means that your code would give an error if you used D2.  In D1, 
'override' is optional, but in D2 it's been made mandatory.

Regardless even if you put 'override' on the subclass's "foo", it wouldn't 
help with your problem; you either have to make a non-virtual call or make 
"foo" final. 




More information about the Digitalmars-d-learn mailing list