Why can't static functions be virtual

Sebastian Biallas groups.5.sepp at spamgourmet.com
Wed Jan 17 09:52:58 PST 2007


John McAuley wrote:
> Are statics non-virtual because that's the way c++ does it?
> 
> Surely the compiler can see base.hello() and then:
> 
> * look up the CBase class definition to find hello
> * get its index in the vtable and note that it is static
> * dereference base to get the CDerived vtable
> * get the address that corresponds to hello
> * call hello without passing base as a secret this pointer

What if hello want to call another "static virtual" function? This
wouldn't work without a this pointer.



More information about the Digitalmars-d mailing list