链表队列出错请大家帮忙看看好吗

#include
using namespace std;

typedef char DataType;
typedef struct QueueNode{
DataType data;
QueueNode*next;
};
typedef struct Queue{
QueueNode*front;
QueueNode*rear;
};

bool IsEmpty(Queue* a){
if (a->front == NULL&&a->rear == NULL){
return true;
}
return false;

}
void addQueueNode(Queue*&a, DataType data){
QueueNode* mNode;
if (a->front == NULL&&a->rear == NULL){
mNode = new QueueNode;
mNode->data = data;
mNode->next = NULL;
a->front = mNode;
a->rear = mNode;
}
else{
mNode = new QueueNode;
mNode->data = data;
mNode->next = NULL;
a->rear->next = mNode;
a->rear = mNode;
}
}
DataType deleteQueueNode(Queue*a){
if (a->front == NULL&&a->rear == NULL){
return NULL;
}
if (a->front == a->rear){
DataType mData = a->front->data;
QueueNode*mstr = a->front;
a->front = NULL;
a->rear = NULL;
delete[]mstr;
return mData;
}
else{
QueueNode*mstr = a->front;
a->front = a->front->next;
DataType mData = mstr->data;
delete[]mstr;
return mData;
}

}

int main(){

Queue *a = new Queue;
a->front == NULL;
a->rear == NULL;
addQueueNode(a, 'A');
addQueueNode(a, 'B');
addQueueNode(a, 'B');
cout << deleteQueueNode(a) << endl;
system("PAUSE");
return 0;

}
求解错误出在哪里 如何改正 为什么出错

查看全部
jameshuang2002q
jameshuang2002q
2015/05/27 11:48
  • 链表
  • 点赞
  • 收藏
  • 回答
    私信

1个回复