我在基本运算符重载方面遇到了麻烦。我正在使用以下课程:
template <class T>
class Node
{
public:
Node() {value = NULL; next = NULL; prev = NULL;}
T* value;
Node* next;
Node* prev;
};
class fixedList
{
public:
class fListIterator
{
public:
Node<T>* point;
fListIterator & operator=(Node<T>* x) {point = x; return this}
};
Node<T>* first;
Node<T>* last
fListIterator begin() {fListITerator a = first; return a;}
}
template <class T> fixedList<T>::fixedList(int x, T y)
{
Node<T> data[x];
for (int z = 0; z < x; z++)
{
data[0].value = &y;
}
first = &data[0];
last = &data[x-1];
Node<T>* assign = first;
for (int i = 0; i < x - 1; i++)
{
Node<T>* temp = new Node<T>;
temp = &data[i];
assign->next = temp;
assign->next->prev = assign;
assign = assign->next;
}
}
int main(int argc, char** argv)
{
fixedList<int>* test = new fixedList<int>(5, 2);
fixedList<int>::fListIterator a = test->begin();
return 0;
}
我在 begin() 函数中不断收到错误:“请求从 'Node*' 转换为非标量类型 'fixedList::fListIterator'”
谁能弄清楚我做错了什么?
编辑:抱歉,我试图保持紧凑。