Overloading/Inheritance issue

BCS ao at pathlink.com
Sun Aug 5 14:50:37 PDT 2007


Reply to Chris Nicholson-Sauls,

> What we really need is a fix for the problem of casting to a Base
> class "forgetting" overrides.  Maybe a change to how vtbls work?
> Okay, an example:
> 
> class Base {
> int foo () { return 1; }
> }
> class Derived : Base {
> override int foo () { return 2; }
> }
> What I'm thinking, is that Derived's copy of Base's vtbl should have
> the pointer for .foo replaced with a pointer to its override.  That
> way, when cast to Base the entry still points to Derived's method.
> Assuming the vtbl is prepared at compile-time, this shouldn't cause
> any runtime issues... should it?
> 

Unless I'm totally misreading you, that IS how it works.





More information about the Digitalmars-d mailing list