www.digitalmars.com         C & C++   DMDScript  

D - bug in template subclasses

reply "Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> writes:
Hi,

    The following code doesn't compile.


template A(T) {
    public interface I {
        public T i();
    }
}
class B : instance A(int).I {
    public int i() {
        return 42;
    }
}
int main() {
    B b = new B();
    instance A(int).I i = b;
    printf("B.i -> %d\r\n", b.i());
    printf("I.i -> %d\r\n", i.i());
    return 0;
}


    The inheritance declaration of B doesn't accept a anonymous template
instance, but accepts a qualified one.

    Best regards,
    Daniel Yokomiso.

"Alcohol & calculus don't mix. Never drink and derive."
Dec 02 2002
parent "Walter" <walter digitalmars.com> writes:
Ok, I see what's going wrong. Thanks, -Walter

"Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> wrote in message
news:asgbf3$2uov$1 digitaldaemon.com...
 Hi,

     The following code doesn't compile.


 template A(T) {
     public interface I {
         public T i();
     }
 }
 class B : instance A(int).I {
     public int i() {
         return 42;
     }
 }
 int main() {
     B b = new B();
     instance A(int).I i = b;
     printf("B.i -> %d\r\n", b.i());
     printf("I.i -> %d\r\n", i.i());
     return 0;
 }


     The inheritance declaration of B doesn't accept a anonymous template
 instance, but accepts a qualified one.

     Best regards,
     Daniel Yokomiso.

 "Alcohol & calculus don't mix. Never drink and derive."

Dec 03 2002