Template Inheritance
Jonathan M Davis
jmdavisProg at gmx.com
Sat Feb 18 17:07:01 PST 2012
On Sunday, February 19, 2012 00:55:59 %u wrote:
> I've been working on porting an old D library to D2, and I'm running into a
> nasty issue with templates and inheritance. I've got a base class like this:
>
> class Reader {
> void get(T)(ref T[] buffer);
> }
>
> and a subclass like this:
>
> class SubReader {
> void get()(SomeClass param);
> }
>
> The problem is that by creating a new form of the template in the subclass,
> I made the base class's version invisible. If I try to use "alias
> Reader.get get" like I would do for functions, the compiler complains that
> the symbols clash (no musical puns intended). Does anyone know how to get
> this to work?
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
More information about the Digitalmars-d-learn
mailing list