www.digitalmars.com         C & C++   DMDScript  

D - interfaces not inherited

reply Patrick Down <pat codemoon.com> writes:
So I gather from the following message that
interfaces on a class are not inherited?

err.d(28): cannot implicitly convert Fred to Foo

interface Foo
{
  void doTheThing();
}

class Bar : Foo
{
  void doTheThing()
  {
    printf("one\n");
  }
}

class Fred : Bar
{
  void doTheThing()
  {
    printf("two\n");
  }
}

int main(char[][] args)
{
  Fred f = new Fred();
  
  Foo fi = f;
  
  fi.doTheThing();
  
  return 0;
}
Sep 04 2002
parent reply Joe Battelle <Joe_member pathlink.com> writes:
So I gather from the following message that
interfaces on a class are not inherited?
Interfaces are broken in a couple ways--this being one side effect. See my earlier bug reports about this in the newsgroup. I don't know when Walter plans a fix.
Sep 05 2002
next sibling parent reply Patrick Down <pat codemoon.com> writes:
Joe Battelle <Joe_member pathlink.com> wrote in
news:al70cj$1pn9$1 digitaldaemon.com: 

So I gather from the following message that
interfaces on a class are not inherited?
Interfaces are broken in a couple ways--this being one side effect. See my earlier bug reports about this in the newsgroup. I don't know when Walter plans a fix.
Yes, the following prints "One" which isn't right any way you look at it. interface Foo { void doTheThing(); } class Alpha : Foo { void doTheThing() { printf("One\n"); } } class Beta : Alpha, Foo { void doTheThing() { printf("Two\n"); } } void func(Foo theFoo) { theFoo.doTheThing(); } int main(char[][] argv) { Beta b = new Beta(); func(b); return 0; }
Sep 06 2002
parent reply Patrick Down <pat codemoon.com> writes:
Patrick Down <pat codemoon.com> wrote in 
news:Xns9281E2CE8BD23patcodemooncom 63.105.9.61:

 Yes, the following prints "One" which isn't right
 any way you look at it.
Disregaurd my post this seems to work. There does seem to be something odd about the way interfaces are working but I haven't pinned it down yet.
Sep 07 2002
parent Joe Battelle <Joe_member pathlink.com> writes:
Disregaurd my post this seems to work.  There does
seem to be something odd about the way interfaces
are working but I haven't pinned it down yet.
Again, save yourself some time--read my thread on this in the group from a couple weeks ago.
Sep 07 2002
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Joe Battelle" <Joe_member pathlink.com> wrote in message
news:al70cj$1pn9$1 digitaldaemon.com...
So I gather from the following message that
interfaces on a class are not inherited?
Interfaces are broken in a couple ways--this being one side effect. See
my
 earlier bug reports about this in the newsgroup.  I don't know when Walter
plans
 a fix.
I haven't forgotten about it. I intend to focus on it after implementing raii. It's not a trivial problem and I want to clear the table of distractions <g>. -Walter
Sep 12 2002