注册 登录
编程论坛 C语言论坛

不能将xxx类型的值分配到xxx类型的实体,麻烦大佬能帮我看看,我自己怎么看都觉的没问题

q386863114 发布于 2020-05-06 14:31, 1921 次点击
#include <iostream>
using namespace std;

typedef struct
{
    int x;
    struct QNode *next;
}QNode, *Queueptr;
typedef struct
{
    Queueptr rear;
}LinkQueue;

int main()
{
    return 0;
}
void InitLinkQueue(LinkQueue &Q)
{
    Q.rear = new QNode;
    Q.rear->next = Q.rear; //这里报错 :不能将 "Queueptr" 类型的值分配到 "QNode *" 类型的实体
}
3 回复
#2
lin51616782020-05-06 14:41
typedef struct QNode
{
    int x;
    struct QNode *next;
}QNode, *Queueptr;
#3
q3868631142020-05-06 14:47
回复 2楼 lin5161678
加上不报错了,但是这是什么原因呢,我不是设置了别名QNode了么,为啥结构体名字还非要写上呢
#4
lin51616782020-05-06 15:17
8行设置了新名字
你的next写在第7
1