Class and Interface Fun
Tim M
a at b.com
Sat Jan 24 20:40:08 PST 2009
On Sun, 25 Jan 2009 16:43:55 +1300, John Reimer <terminal.node at gmail.com>
wrote:
> With this code:
>
> --------------------------------
>
> module test5;
>
> interface I
> {
> void foo();
> }
>
> class A : I {
> void foo() { }
> }
>
> class B : A, I
> {
> alias A.foo foo;
> }
> void main()
> {
> }
>
> --------------------------------
>
> I get this error:
>
> --------------------------------
>
> class test5.B interface function I.foo is not implemented
>
> --------------------------------
>
> Does this make sense? I mean, shouldn't the explicit reuse of A.foo in
> B be sufficient indication to the compiler that B is satisfying the
> contract I? I'm hoping to make use of such subtleties in some code,
> but first I have to understand the reasoning behind this. :)
>
> Note that this works if I remove the interface I from B's declaration --
> ie "class B: A" -- since, in the D language, B is not required to
> fulfull A's interface contract even though it inherits from it. -JJR
>
>
It look like the real bug is re-allowing B to implement interface I but
sometimes bug do get reported differently. Why don't you remove I from B's
declaration like you said that works. It actually says here
http://www.digitalmars.com/d/1.0/interface.html "Classes cannot derive
from an interface multiple times."
More information about the Digitalmars-d-learn
mailing list