如何在队列中存储BST节点的地址? [英] How to store address of BST node in a queue?

查看:112
本文介绍了如何在队列中存储BST节点的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quote:

警告:在没有演员的情况下从指针生成整数:

注意 - > Bstnode是一个二进制树放大器的节点是队列的结构

Warning: makes integer from pointer without a cast:
Note->Bstnode is a node of binary tree amp is structure of queue









这是我的错误吗我得到的是由于amp->; array [amp-> rear] = root;因为root是一个指针如果那样的话,如果我想存储struct Bstnode的地址,那就是队列中BST节点的地址。请指出我的错误



我尝试过:







Is this error that I am getting is due to amp->array[amp->rear]=root; because root is a pointer If then what will be the way if I want to store the address of struct Bstnode that is the address of nodes of BST in a queue. Please give a pointer to my error

What I have tried:

void enqueue(struct queue* amp,struct Bstnode* root){
    if(isfull(amp))
       return;
    else if(isempty(amp))
    {
       amp->rear=0;
       amp->front=0;
       amp->array[amp->rear]=root;
    }
    else
    {
        amp->rear=((amp->rear+1)%(amp->capacity));
        amp->array[amp->rear]=root;
    }

}

推荐答案

您不能将指针用作数组偏移量。如果 amp-> rear 是一个指针,那么你必须将它用作指针。将它作为一个整数值用作数组索引会更有意义。
You cannot use a pointer as an array offset. If amp->rear is a pointer then you must use it as a pointer. It would make more sense to make it an integer value to use as an array index.


这篇关于如何在队列中存储BST节点的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆