Overloading/Inheritance issue

Walter Bright newshound1 at digitalmars.com
Fri Aug 3 22:48:02 PDT 2007


Sean Kelly wrote:
> Walter Bright wrote:
>> I agree that this example is a problem. There's no way to detect it at 
>> compile time, so it should throw a runtime exception. The way to 
>> accomplish that is to stuff D's vtbl[] entry for B.set(int) with a 
>> dummy function that throws the exception.
> 
> Certain C++ compilers have done something like this in the past, if I 
> remember correctly.  I'd have to do some googling to remember the 
> details, but I'm sure it was either the MS or Sun compiler.

I didn't know that. This particular problem may not come up so often 
with C++ because functions are not virtual by default - but not virtual 
by default produces its own set of very hard to find bugs that I've 
wasted many hours tracking down.



More information about the Digitalmars-d mailing list