#include<iostream>
#include<conio.h>
#include<string.h>
#define OK 1
#define MAXSIZE 100
using namespace std;
typedef int Status;
#define OK 1
typedef struct
{
char name[5];
float price;
}Book;
typedef struct LNode
{
Book Elem;
LNode *next;
}LNode,*List;
Status InitList(LNode *L)
{
L=new LNode();
if(!L)
exit(-1);
else
L->next=NULL;
return OK;
}
int main()
{
LNode *L;
List LL;
InitList(L);
cout<<(*L)->next;
getch();
return 0;
}
我仅仅完成了链表的初始化,为啥报错呢?
--------------------Configuration: 线性表 - Win32 Debug--------------------
Compiling...
线性表.cpp
E:\数据结构\线性表.cpp(39) : error C2819: type 'LNode' does not have an overloaded member 'operator ->'
E:\数据结构\线性表.cpp(17) : see declaration of 'LNode'
E:\数据结构\线性表.cpp(39) : error C2227: left of '->next' must point to class/struct/union
Error executing cl.exe.
线性表.exe - 2 error(s), 0 warning(s)