i am trying to implement a LinkList class with a struct as my private member, however, when i try to define the struct ListNode under the LinkList.ccp, the compiler says that the pointer is not defined. The error is on the high lighted line
#ifndef LINKLIST_H
#define LINKLIST_H
#include <iostream>
using namespace std;
template <typename T>
class LinkList{
private:
struct ListNode{
T item;
ListNode * next;
};
int size; // the size of the listNodes.
ListNode* _head;
public:
LinkList(); // constructor
void giveup(int n);
bool isEmpty();
int getLength();
ListNode * find(int index);
};
#endif
#include "LinkList.h"
template <typename T>
LinkList<T>::LinkList(){
_head = NULL;
size = 0;
}
template <typename T>
void LinkList<T>::giveup(int n){
cout << "The error " << n << " has occured" << endl;
}
template <typename T>
bool LinkList<T>::isEmpty(){
return (size == 0);
}
template <typename T>
int LinkList<T>::getLength(){
return size;
}
template <typename T>
***ListNode * LinkList<T>::find(int index){ // pointer not defined***
if(index < 1 || index > size){
return NULL;
}
ListNode * currentNode = _head;
for(int pos =2; pos <=index; pos++){
currentNode = currentNode->next;
}
return currentNode;
}