我試圖使用重載操作符方法將一個隊列的條目複製到另一個隊列中,但我的功能出錯了。我不知道怎麼回事訪問隊列「原始」的任何其他方式的價值比我有如下:隊列C++的操作符重載
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;
}
}
已經有一個'std :: queue'類。 – Griwes 2012-04-09 23:27:20