I have a template node class that I have been using in some projects for creating linked lists with. Now I am trying to create a template class for working with sets. For some reason tho when I try to declare my node pointer in the template set class it is giving me an error saying that it cannot declare node without a type. Here is the code:
Node class
Code:
template <class T>
class node{
public:
node(){linkfield = NULL;}
node(T d, node *lf){datafield = d; linkfield = lf;}
T& data(){return datafield;}
node * link(){return linkfield;}
void setData(T d){datafield = d;}
void setLink(node * lf){linkfield = lf;}
private:
T datafield;
node * linkfield;
};
Set class
Code:
template <class T>
class Set{
public:
Set();
Set(const Set& other);
~Set();
bool is_element(T d);
bool is_subset(const Set<T> other);
void insert(T d);
void input();
void output();
Set unian(const Set<T> other);
Set intersect(const Set<T> other);
void operator =(const Set<T>& other);
private:
node <T> * head;
};
Besides the node template class I haven't worked with templates at all so I'm not sure if this is some little syntax error or a bigger problem in calling a template class from a template class.
Thanks
-alex