I've been provided with a code to create a doubly-linked list. A node in the linked list is a struct by the name of ListItem. Now within that node is a function that assigns a value to the node. The problem that I'm having is that I can't seem to create a node and use the function to assign the value to it.
Here's the code for the struct "ListItem".
template <class T>
struct ListItem
{
T value;
ListItem<T> *next;
ListItem<T> *prev;
ListItem(T theVal)
{
this->value = theVal;
this->next = NULL;
this->prev = NULL;
}
};
The corresponding ListItem functions in the accompanying .cpp file:
template <class T>
ListItem<T>* List<T>::getHead()
{
}
template <class T>
ListItem<T>* List<T>::getTail()
{
}
template <class T>
ListItem<T> *List<T>::searchFor(T item)
{
}
Here's what I was attempting to do in my main function.
int main()
{
ListItem<int> a;
a.ListItem(int 5);
system("PAUSE");
}
All I'm trying to do here is create a node and assign a value to it. Following are the errors I'm getting:
='a' is not a class or namespace
=missing template arguments before '(' token
=expected primary expression before 'int'