base class method can implement base base interface method, is it designed?

redsea redsea at 163.com
Thu Aug 16 01:01:54 PDT 2007


I found an interesting thing,  can not found definition in specification.

the following program is invalid,  dmd said:

test.d(19): class test.B interface function I.testI is not implemented
---------------
import tango.io.Stdout;
alias Stdout o;

interface I
{
  public abstract void testI();
}

class A
{
 public void testI(){o(1).newline;}
}

interface IB: public I
{
}


class B : public A, public I
{
};


void main()
{
I i = new B;
i.testI();
}
---------------

but if change the class B to:

class B : public A, public IB

dmd would not complain , and the output binary can run correctly.

---------------
I like base class method can use to implement interface, or use delphi's method, a class can delegate interface implement to base class member.

But currently situation is some strange, perhaps it is not a designed feature ?




More information about the Digitalmars-d mailing list