我正在使用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