Hi I tried to create a List Class. But in order to have a variation of list class, I am using template to store value in item variable.
Below is in "List.h"
template <class ListItemType>
class List
{
public:
.........
.........
private:
struct ListNode
{
ListItemType item;
ListNode *next;
};
int size;
ListNode *head;
ListNode *find(int index) const;
};
Then how do I create the implementation of "ListNode *find(int index) const" function in List.cpp?
I tried to use
template <class ListItemType>
List<ListItemType>::ListNode *List<ListItemType>::find(int index) const
{
........
}
But there is an error saying "error: need 'typename' before 'List::ListNode' because 'List' is a dependent scope"
Do you know how do I implement "ListNode *find(int index) const" in List.cpp?
This is my first time using template, I am a bit confuse. Thanks