我正在使用C++實現鏈表。我在LinkedList.h中創建了一個struct Node,並嘗試在節點中重載運算符。但是,當我編譯,我得到這個錯誤 代碼:爲鏈表創建節點C++
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
class LinkedList{
typedef struct Node{
int data;
Node* next;
} * nodePtr;
//Returns true if the current Node object value is
//less than the parameter Node object value
bool operator < (const Node& node) const {
return this->data < node->data; <--- Unable to resolve identifier data.
};
#endif /* LINKEDLIST_H */
我不知道我做錯了什麼。有人能告訴我嗎?! 謝謝!
我改變它爲node.data,但直到有同樣的問題。我想將此節點的數據與傳入的節點的數據節點進行比較。 – Jnk 2014-09-25 22:17:47