February 25, 2004 Templated Classes and Inheritance | ||||
---|---|---|---|---|
| ||||
Alright, so I'm implementing a class called Queue (Bet you can't guess what that one does!). Anyways, Queue inherits from a class called Array, which provides an Object[] member variable and appropriate accessor methods. It also implements the Enqueue interface which defines push() and pop() methods. Until now, Queue has only handle Objects. But now I've been trying to had support for primitve types by means of templating. However, I've hit a snag. If I instantiate a Queue!(char[]), I need it to inherit from Array!(char[]) instead of Array!(Object). Also, it needs to implement Enqueue!(char[]) instead of Enqueue!(Object). Is there a syntax to do this? And if so, what is it? Thanks, Owen |
Copyright © 1999-2021 by the D Language Foundation