这是在我试图用链表来实现队列代码: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