编译出错, 但发现并不缺少提示问题 missing ')' before '&' 请教大家了,谢谢.
不知道为什么,老出这种问题.
在.h文件中声明函数,为什么会出这样错误呢? 不能这样用吗?以前可以的呀.struct Linklist *&L
#include<malloc.h>
typedef char Elemtype;
struct Linklist
{
Elemtype data;
struct Linklist *next;
};
//头插法建表.适用于初始化链表,一次输入多个多个节点数据情况.
struct Linklist* CreatListHead(struct Linklist *L);
void InitList(struct Linklist *&L);
//尾插法建表.
struct Linklist*CreatListTail(struct Linklist *L);
--------------------Configuration: Linklist - Win32 Debug--------------------
Compiling...
main.c
f:\myprog\linklist\linklist.h(18) : error C2143: syntax error : missing ')' before '&'
f:\myprog\linklist\linklist.h(18) : error C2143: syntax error : missing '{' before '&'
f:\myprog\linklist\linklist.h(18) : error C2059: syntax error : '&'
f:\myprog\linklist\linklist.h(18) : error C2059: syntax error : ')'
f:\myprog\linklist\linklist.h(28) : error C2143: syntax error : missing ')' before '&'
f:\myprog\linklist\linklist.h(28) : error C2143: syntax error : missing '{' before '&'
f:\myprog\linklist\linklist.h(28) : error C2059: syntax error : '&'
f:\myprog\linklist\linklist.h(28) : error C2059: syntax error : ')'
f:\myprog\linklist\linklist.h(40) : error C2143: syntax error : missing ')' before '&'
f:\myprog\linklist\linklist.h(40) : error C2143: syntax error : missing '{' before '&'
f:\myprog\linklist\linklist.h(40) : error C2059: syntax error : '&'
f:\myprog\linklist\linklist.h(40) : error C2059: syntax error : ')'
f:\myprog\linklist\main.c(8) : warning C4013: 'InitList' undefined; assuming extern returning int
Error executing cl.exe.
main.obj - 12 error(s), 1 warning(s)
[解决办法]
用双*吧。。。。你这个太别扭,在调用的时候可以这样用
[解决办法]
InitList这个函数
如果参数是个结构指针的话,那就是
void InitList(struct Linklist *L);
如果参数是个结构指针的指针的话,那就是
void InitList(struct Linklist **L);
不能void InitList(struct Linklist *&L); 定义