威塞哥有中国:想知道是什么问题,编译总是过不了? 请指教、、

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/30 05:54:49
template <class T,int size1,int size>
bool CreateSL(SLinkList<T,size1>&L,T(&array)[size]){ //根据数据数组创建链表
if(size>=size1)return false; //数组太长就失败
Pointer p=L.Malloc(); //为头指针分配内存
L.Next()=p;
for(int i=0;i<size;i++){
L.SetData(p,array[i]);
if(i<size-1)
L.Next(p)=L.Malloc(),p=L.Next(p);
}
L.Next(size)=NULL; //尾指针为空
return true;
}

编译的时候总是在第2句处提示错误如下:
error C2265: '<Unknown>' : reference to a zero-sized array is illegal

char* str[]={"ZHAO","QIAN","SUN","LI","ZHOU","WU","ZHENG","WANG"};
SLinkList<char*>L;
CreateSL(L,str);
这3句是主函数里的 第3句提示也有错误如下:error C2784: 'bool __cdecl CreateSL(class SLinkList<T,size1> &,T (&)[1])' : could not deduce template argument for ' (&)[1]' from 'char *[8]'

T(&array)[size]) 这句也不是很好理解? 能讲解下吗?
要怎么样修改才能编译过呢? 希望你们具体讲解下(为什么要改了才正确? ) 谢谢、、

SLinkList怎么定义的?
上面SLinkList<T, size1>
而下面SLinkList<char*>L;?