#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(List *L)
{
L=new List();
if(!L)
exit(-1);
else
(*L).next=NULL;
return OK;
}
int main()
{
LNode L;
L.Elem.price=1;
List * LL;
getch();
return 0;
}
为什么会报错
--------------------Configuration: 线性表 - Win32 Debug--------------------
Compiling...
线性表.cpp
E:\数据结构\线性表.cpp(29) : error C2228: left of '.next' must have class/struct/union type
Error executing cl.exe.
线性表.exe - 1 error(s), 0 warning(s)
大概是
(*L).next=NULL;
出了问题。我很纳闷,*L整体是个值结构体类型,给地址赋值,这么写没有问题啊