Template Inheritance

Jonathan M Davis jmdavisProg at gmx.com
Sun Feb 19 04:37:26 PST 2012


On Sunday, February 19, 2012 12:34:07 Jacob Carlborg wrote:
> > Template functions are non-virtual. You can't derive from them. If you
> > want
> > the derived classes to have the same functions, you must redefine them in
> > the derived class.
> > 
> > - Jonathan M Davis
> 
> Yeah, but isn't that an overload, or specialization, in the subclass?

Yes. But if you're trying to give the function different behavior in the 
derived class, what else can you do? Of course, it won't work with 
polymorphism though (the version that gets called will depend on the reference 
that you're using), so it may not be such a good idea from that standpoint.

Really, templated functions and class hierarchies don't get along very well.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list