我一直在爲我的某個函數獲取編譯器錯誤。C++:關於鏈表的實現
LinkedList.hpp:81: error: `template<class T> class LinkedList' used without template parameters
LinkedList.hpp:81: error: expected constructor, destructor, or type conversion before '*' token
LinkedList.hpp:81: error: expected `;' before '*' token
但事情是我有一個構造函數,析構函數和類型轉換。我敢肯定的是,執行是錯誤的
// This is the function i keep on getting an error for
template <class T>
ListNode* LinkedList<T>::find(int pos)//Finds the position of an item
{
if(pos < 1)
return NULL; //If pos is less than one then find returns NULL because pos is a illegal value.
else
{
ListNode *temp = head;
for(int i = 1; i < pos; i++)
temp = temp -> next;
return temp;
}
}
//The class
template <class T>
class LinkedList : public ABCList<T> {
private:
//T a [LIST_MAX];
struct ListNode
{
T data; // List item
ListNode *next; //Pointer to next node
};
int size;
ListNode *head;
ListNode *find(int pos);
public:
LinkedList();
LinkedList(LinkedList &other);
~LinkedList();
virtual bool isEmpty() = 0;
virtual int getLength() = 0;
virtual void insert (int pos, T item) = 0;
virtual T remove (int pos) = 0;
virtual T retrieve (int pos) = 0;
};
哪裏代碼你在哪裏,你創建一個LinkedList對象? – imreal
81線在哪裏? –
線81'code'template ListNode * LinkedList的 ::發現(INT POS) –