使用队列实现树(链接列表实现)
我正在尝试使用队列(链接列表实现)为树进行预订的遍历编码,
#include<iostream>
using namespace std;
class Node{
public:
int data;
Node *rchild;
Node *lchild;
};
class Queue{
private:
Node *front;
Node *rear;
public:
Queue();
void enqueue(Node* x);
int dequeue();
bool isEmpty();
bool isFull();
void display();
};
void enqueue(Node *x){
Node *t = new Node;
if(t == NULL) cout<<"Overflow!;
else{
rear++;
rear->data = x;
而我正在执行后部 - data; data = x;此语句无效,因为X不是整数。
我应该如何继续?
I am trying to code preorder traversal for a tree using queue(linked list implementation)
#include<iostream>
using namespace std;
class Node{
public:
int data;
Node *rchild;
Node *lchild;
};
class Queue{
private:
Node *front;
Node *rear;
public:
Queue();
void enqueue(Node* x);
int dequeue();
bool isEmpty();
bool isFull();
void display();
};
void enqueue(Node *x){
Node *t = new Node;
if(t == NULL) cout<<"Overflow!;
else{
rear++;
rear->data = x;
Now when i am doing rear->data = x; this statement is not valid because x is not an integer.
How should i proceed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论