オーバーロード演算子メソッドを使用して、あるキューのエントリを別のキューにコピーしようとしましたが、関数が間違っています。以下にある方法以外の方法で、キューの「元の」値にアクセスする方法がわかりません。
struct Node
{
int item;
Node* next;
};
class Queue
{
public:
// Extra code here
void operator = (const Queue &original);
protected:
Node *front, *end;
};
void Queue::operator=(const Queue &original)
{
//THIS IS WHERE IM GOING WRONG
while(original.front->next != NULL) {
front->item = original.front->item;
front->next = new Node;
front = front->next;
original.front = original.front->next;
}
}