Class templates deriving from base class

Ary Borenszweig ary at esperanto.org.ar
Thu Nov 26 13:11:00 PST 2009


Michael Mittner wrote:
> Hi!
> 
> I'm trying to do something like this (in D1):
> 
> class Foo
> {
>     // ...
> }
> 
> class Bar(T) : Foo
> {
>     // ...
> }
> 
> alias Bar!(int) IntBar;
> alias Bar!(Mars) MarsBar;
> 
> void main()
> {
>     Foo x = new MarsBar();
> }
> 
> Common base class, one derived template class and a bunch of aliases that 
> are then actually used in the code. But it seems like deriving a template 
> class from a non-template one doesn't work. Is this supposed to work, am I 
> doing something wrong or am I out of luck here?
> 
> -Mike

Hi Mike,

Why do you mean with "doesn't work"? If I define class Mars {} and 
compile your program it gives no error. Can you show the error the 
compiler is giving you? (you normally past the compiler output if a 
program doesn't compile so that others can help you faster... but in 
case it compiles, weird :-P)


More information about the Digitalmars-d-learn mailing list