www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Inherit from class template?

reply James Dunne <james.jdunne gmail.com> writes:
Why can I not inherit from a class template?  I get an error saying the template
can't be used as a type.

For one thing, the error message is misleading, because you can use the template
class as a type - to declare a variable of that type as well as use it in the
new operator.

What is the issue impeding using class templates as parent classes?

Regards,
James Dunne
Aug 28 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"James Dunne" <james.jdunne gmail.com> wrote in message 
news:desvq8$12b6$1 digitaldaemon.com...
 Why can I not inherit from a class template?  I get an error saying the 
 template
 can't be used as a type.

 For one thing, the error message is misleading, because you can use the 
 template
 class as a type - to declare a variable of that type as well as use it in 
 the
 new operator.

 What is the issue impeding using class templates as parent classes?

 Regards,
 James Dunne
Did you supply a template parameter? eg class Foo(T) {...} class Bar : Foo!(int) {...} class Baz(T) : Foo!(T) {...}
Aug 28 2005
parent James Dunne <james.jdunne gmail.com> writes:
In article <det0er$133b$1 digitaldaemon.com>, Ben Hinkle says...
"James Dunne" <james.jdunne gmail.com> wrote in message 
news:desvq8$12b6$1 digitaldaemon.com...
 Why can I not inherit from a class template?  I get an error saying the 
 template
 can't be used as a type.

 For one thing, the error message is misleading, because you can use the 
 template
 class as a type - to declare a variable of that type as well as use it in 
 the
 new operator.

 What is the issue impeding using class templates as parent classes?

 Regards,
 James Dunne
Did you supply a template parameter? eg class Foo(T) {...} class Bar : Foo!(int) {...} class Baz(T) : Foo!(T) {...}
Well, I'll be darned. I swear it was breaking, which was totally weird. But I try it again and it all works. I must've done something weird... I think I shall investigate further. Perhaps I've discovered some obscure special case. Thanks for making me check over my code, Ben! Regards, James Dunne
Aug 28 2005