digitalmars.D - class template erros
Hi all, I am trying to implement a linked list in D and here is the code: In LinkNode.d: module LinkNode; public class Link(T) { private: T data; Link next; public: this() { } this(Link nextNode) { next = nextNode; } this(T item, Link nextNode) { data = item; next = nextNode; } T getElement() { return data; } Link getNext() { return next; } void setElement(T nodeItem) { data = nodeItem; } void setNext(Link nextNode) { next = nextNode; } } In LList.d: module LList; import LinkNode; public class LList(T) { private: Link!(T) head; Link!(T) tail; Link!(T) curr; public: this() { } } In Driver.d: import std.stdio; import std.string; import LList; int main() { LList!(int) var3 = new LList!(int)(); var3.insert(3); var3.nextNode(); writefln("%d",var3.currentValue()); return 1; } When I compile, I get the following erros: C:\LinkedList\Driver.d(8: template instance LList is not a template declaration, it is a import C:\LinkedList\Driver.d(8: Error: LList!(int) is used as a type C:\LinkedList\Driver.d(8: variable Driver.main.var3 voids have no value I have been working on this forever and can't find a solution. Any help would be appreciated. Thanks, Jonathan
Oct 07 2007
Jonathan Wrote:Hi all,[CLIP]JonathanI'm not sure about this, but I think you can't have a class with the same name as a module... Try changing the name of the LList class to LinkList for example.
Oct 07 2007
acarion <asdfa asf .com> Wrote:Jonathan Wrote:The solution worked. Thanks a bunch. You saved a whole bunch of time. JonathanHi all,[CLIP]JonathanI'm not sure about this, but I think you can't have a class with the same name as a module... Try changing the name of the LList class to LinkList for example.
Oct 07 2007