SqList &L与&L?

sunxlbutu 2009-02-08 08:34:28
这是实现顺序表的初始化c程序:
#include "stdio.h"
#include "stdlib.h"

#define OVERFLOW 0
#define OK 1

#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10

typedef struct {
int *elem;
int length;
int listsize;
}SqList;

int InitList_Sq(SqList *L);

int main()
{
SqList L;

InitList_Sq(SqList &L);

system("pause");
return 0;

};

int InitList_Sq(SqList *L)
{
L->elem = (int *)malloc(LIST_INIT_SIZE * sizeof(int));
if(!L->elem) exit(OVERFLOW);

L->length = 0;
L->listsize = LIST_INIT_SIZE;

return OK;
}
其中 InitList_Sq(SqList &L); 出错:
--------------------Configuration: 线性表的顺序表示 - Win32 Debug--------------------
Compiling...
线性表的顺序表示.cpp
F:\MyProject\线性表的顺序表示\线性表的顺序表示.cpp(22) : error C2275: 'SqList' : illegal use of this type as an expression
F:\MyProject\线性表的顺序表示\线性表的顺序表示.cpp(14) : see declaration of 'SqList'
Error executing cl.exe.

线性表的顺序表示.obj - 1 error(s), 0 warning(s)

如果把 InitList_Sq(SqList &L); 改为 InitList_Sq(&L); 后编译就不会出错,这是为什么呢?
...全文
126 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunxlbutu 2009-02-09
  • 打赏
  • 举报
回复
知道原因啦

33,010

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧