qq_43412960 2019-12-22 00:16 采纳率: 78.6%
浏览 345
已采纳

这是 一个关于数据结构的链表问题


#include<iostream>
#include<conio.h>
#include<string.h>
#define OK 1
#define MAXSIZE 100
using namespace std;
typedef  int Status;

typedef  struct  
{
char name[5];
float price;    
}Book;

typedef Book ElemType;

typedef  struct LNode
{
ElemType data;
struct LNode *next;


}LNode,*LinkList;
LNode *A;


Status InitList(LNode *L)
{

L=new LNode;

if(!L)
exit(-1);
else
(*L).next=NULL;
return OK;
}

int main()
{

LNode *L;

InitList(*L);




cout<<L;

getch();


return 0;
}

这是我写的完整代码,就是生成了链表结点,还有初始化链表。

其中,
图片说明

划线部分,两个参数我写的一样的,因为形参和实参要一致

但是却报错

--------------------Configuration: 线性表 - Win32 Debug--------------------
Compiling...
线性表.cpp
E:\数据结构\线性表.cpp(45) : error C2664: 'InitList' : cannot convert parameter 1 from 'struct LNode' to 'struct LNode *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.

线性表.exe - 1 error(s), 0 warning(s)
为甚么呢?

  • 写回答

2条回答 默认 最新

  • 喜欢喝茶的猫 2019-12-22 09:46
    关注

    这个问题是关于 * 的用法,用在声明的时候它指声明一个指针类型的变量,结合指针使用的时候指取指针所指的变量;
    这里说的是你的参数不对,划线部分要保持参数类型一致,应为指针类型,把* 去掉即可

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记