digitalmars.D - template interfaces
- Bruno A. Costa (27/27) Jun 29 2004 Is it possible to write template interfaces in D?
- Hauke Duden (6/42) Jun 29 2004 Try this:
- Bruno A. Costa (3/17) Jun 29 2004 Ok, it worked :) Thanks.
Is it possible to write template interfaces in D? I am making this question because the compiler accepts the following code: interface Foo (T) { public: void do_something (); } class Bar(T) : Foo { // <-- this is line 8 void do_something ( ) { } } //----------------------------- but if I append the main function: int main () { Bar!(int) b = new Bar!(int); return 0; } //----------------------------------------- the compiler returns this error: dmd -c iface.d iface.d(8): template Foo(T) is used as a type iface.d(8): class Bar base type must be class or interface, not void Thanks Bruno. ~
Jun 29 2004
Bruno A. Costa wrote:Is it possible to write template interfaces in D? I am making this question because the compiler accepts the following code: interface Foo (T) { public: void do_something (); } class Bar(T) : Foo { // <-- this is line 8 void do_something ( ) { } } //----------------------------- but if I append the main function: int main () { Bar!(int) b = new Bar!(int); return 0; } //----------------------------------------- the compiler returns this error: dmd -c iface.d iface.d(8): template Foo(T) is used as a type iface.d(8): class Bar base type must be class or interface, not voidTry this: class Bar(T) : Foo!(T) { ... Hauke
Jun 29 2004
Hauke Duden wrote:Bruno A. Costa wrote:Is it possible to write template interfaces in D?Try this: class Bar(T) : Foo!(T) { ... HaukeOk, it worked :) Thanks. Bruno.
Jun 29 2004