abstract function templates

Simen kjaeraas simen.kjaras at gmail.com
Sun Dec 26 15:46:21 PST 2010


Nrgyzer <nrgyzer at gmail.com> wrote:

> I just figured out that this doesn't work, when I use a array with
> super class as base type, for example: Drawable[] textures;
>
> Then, I'll get the following error:
>
> "Error: function draw!(void*).draw non-virtual functions cannot be
> abstract".
>
> I just implemented the draw-function as empty function, which doesn't
> create any errors, but I seems that it's not calling the draw-
> function of any texture instance. It seems that it is always calling
> Drawable.draw() - the empty function. When I create a new instance of
> my Texture-class, it calls the draw-function of the texture-instance.

Yes indeed. This was what I meant by saying that template functions
cannot be virtual. D sadly has no way to create templated functions
that work in a class hierarchy. :(

-- 
Simen


More information about the Digitalmars-d-learn mailing list