#include <iostream>
#include <stdlib.h>
using namespace std;
typedef int QElemNode;
typedef struct QNode
{
QElemNode data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct
{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
typedef int status;
status InitQueue(LinkQueue &Q)
{
Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode));
if(!Q.front)exit(-1);
Q.front->next=NULL;
return 1;
}
void display(LinkQueue &Q)
{
cout<<"结果如下:"<<endl;
while(&Q)
{
cout<<Q.front->data<<endl;
}
}
int main()
{
LinkQueue Q;
Q.front->data=100; //把这段注释了,结果不错了,但全显示0,why?
InitQueue(Q);
display(Q);
return 0;
}