class template erros
Jonathan
j.harlev at gmail.com
Sun Oct 7 08:27:38 PDT 2007
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
More information about the Digitalmars-d
mailing list