SqList &L与&L?

sunxlbutu sunxlbutu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是实现顺序表的初始化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); 后编译就不会出错,这是为什么呢?
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
sunxlbutu
数据结构与算法 33,026 成员 35,334 内容