這是在我試圖用鏈表來實現隊列代碼:FIFO隊列鏈表實現
#include <iostream>
#include <cstdlib>
using namespace std;
template <class Item>
class Queue{
public:
struct node{
Item item;node *next;
node (Item x){
item=x; next=0;
}
};
typedef node* link;
link head, tail;
public:
Queue(int){ head=0;}
int empty() const { return head==0; }
void put(Item x){
node* t=tail;
tail=new node(x);
if (head==0) head=tail;
else t->next=tail;
}
Item get(){
Item v=head->item;link t=head->next;
delete head; head=tail return v;
}
};
int main(){
return 0;
}
,但我有指針的問題。例如,當我寫Item v = head->
它應該顯示我選擇項目的選項,但它不顯示。也在其他地方的代碼 - >這個標誌碼不給我選擇項目或下一個的可能性。請幫忙。
您可以發佈具體的問題,包括適當的錯誤輸出,錯誤消息和所需的輸出。也請使用句子,你的問題很難閱讀。 – 2010-08-30 12:26:27
考慮'它應該讓我選擇':你想讓你的IDE(你的編輯器)顯示一個'head's成員列表嗎?或者是其他東西? – phimuemue 2010-08-30 12:26:33
是的成員,但它不顯示我 – 2010-08-30 12:36:21