virtual functions changing from protected to private - question
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Sep 5 13:19:15 PDT 2006
"MatthiasM" <dm at matthiasm.com> wrote in message
news:edkk0f$2nf4$1 at digitaldaemon.com...
>
> So, umm, after debugging my app for quite a while (OSX gdc), I saw that
> B.draw is not called. Is that intentional?
> I would have expected "MenuWindow", thinking that all functions are
> automatically virtual. I understand that private unctions are not virtual
> on a base class, since they can't be overridden anyways. But is that true
> for a derived class too?
Since you've made it private, the compiler makes it nonvirtual. Since it's
nonvirtual, it doesn't live in the virtual table at all. So it doesn't
override the Window.draw(). Virtual methods and nonvirtual methods live in
two different places, so it's not really possible to override a virtual
method with a nonvirtual method.
More information about the Digitalmars-d-learn
mailing list