C ++中的树实现:无法将Node转换为int *问问题

问题描述 投票:0回答:1

我目前正在做作业。下面是我编写的用于构建二叉树的程序。我收到错误消息:“无法在分配中将'node >>转换为'int *'”。您能在这里帮我吗?**

#include<iostream>
#include<conio.h>

struct node
{
    char data;
    int *left,*right;
};

int main()
{
    node *T; //ROOT of tree
    node *p,*q; //address of first node in T
    T=new node;
    T->left=NULL;
    T->right=NULL;
    T->data='A';


    p=new node;
    p->left=NULL;
    p->right=NULL;
    p->data='B';
    T->left=&p;

    p=new node;
    p->left=NULL;
    p->right=NULL;
    p->data='C';
    T->right=&p;

    q=new node;
    q->left=NULL;
    q->right=NULL;
    q->data='D';
    p->left=&q;

    return 0;
}```

我目前正在做作业。下面是我编写的用于构建二叉树的程序。我收到错误消息:“无法在分配中将'node'转换为'int *'”。可以请...

c++ data-structures binary-tree binary-search-tree nodes
1个回答
0
投票

将结构定义更改为

© www.soinside.com 2019 - 2024. All rights reserved.