'override' question
Sean Kelly
sean at f4.ca
Tue Feb 6 09:11:09 PST 2007
kris wrote:
> given a base class with method write():
>
> # protected uint write() {printf("base\n");}
> #
> # void func()
> # {
> # write ();
> # }
> #
>
> And subclass Sub with method write():
>
> # private override uint write() {printf("sub\n");}
>
>
> What should happen (a) at compile time, and (b) at runtime when invoking
> Sub.func?
Good question :-) I'd say it should print "base" but a subclass of Sub
gets another chance to override write() since it can't see Sub.write().
It would make more sense if it were an error to have a private
override method.
Sean
More information about the Digitalmars-d
mailing list