#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)
为甚么呢?