Inheritance from multiple interfaces with the same method name
Q. Schroll
qs.il.paperinik at gmail.com
Thu Dec 7 21:12:30 UTC 2017
On Thursday, 7 December 2017 at 15:14:48 UTC, Adam D. Ruppe wrote:
> On Thursday, 7 December 2017 at 00:45:21 UTC, Mike Franklin
> wrote:
>> // Error: A.f called with argument types () matches both:
>> A.f() and A.f()
>> // Yeah, that error message could be better.
>> //a.f();
>>
>> (cast(I)a).f(); // prints "void f()"
>> (cast(J)a).f(); // prints "int f()"
>
>
> D also allows you to simply write:
>
> a.I.f();
> a.J.f();
>
> also works for explicitly calling a base class implementation
> btw
This implies that I cannot implement two syntactically identical
methods with different implementations, like if J had void f();
too, I cannot have different implementations for I.f() and J.f().
That would be relevant if they should behave differently e.g. if
they have conflicting contracts.
More information about the Digitalmars-d
mailing list