interface not able to use functions from base classes??

Todd VanderVeen tdvanderveen at gmail.com
Wed Dec 25 08:05:09 PST 2013


On Wednesday, 25 December 2013 at 09:44:32 UTC, Øivind wrote:
>> Strictly speaking B does not implement function and inhereting 
>> function from base class is not the same as implementing the 
>> function.
>
> Yes, but it really seems like this is something that could and 
> should work..
>
>> If you control class A and its appropriate to declare the 
>> interface there, you can declare that A implements I and have 
>> B simply inherit it from A.
>
>> If you only intend to introduce the interface on B, you still 
>> need to provide an implementation for I, either voluntarily 
>> overriding A or providing an alternate implementation to the 
>> virtual interface.
>
> My case is a single base class 'Base' and multiple subclasses 
> grouped under different interfaces.. e.g.
>
> class Base {}
>
> class A : Base, I0 {}
> class B : Base, I0 {}
> class C : Base, I1 {}
>
> I need access to functionality provided in Base through the 
> interfaces I0, I1, ...
>
> It really sucks having to re-implement this functionality in 
> all the subclasses, e.g. A, B, C.. Seems very unnecessary. I 
> finally implemented this using a mixin template, so the actual 
> code for it isn't that big, but still..



More information about the Digitalmars-d mailing list