View mode: basic / threaded / horizontal-split · Log in · Help
August 28, 2005
Inherit from class template?
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
August 28, 2005
Re: Inherit from class template?
"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) {...}
August 28, 2005
Re: Inherit from class template?
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
Top | Discussion index | About this forum | D home