February 06, 2007
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?
February 06, 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