基本的な演算子のオーバーロードに問題があります。私は次のクラスで作業しています:
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' への変換が要求されました」
誰かが私が間違っていることを理解できますか?
編集: 申し訳ありませんが、コンパクトに保とうとしていました。