我是用vc++编的c程序 分了3格文件
一,sqlist.h
#define ture 1
#define palse 0
#define ok 1
#define error 0
#define overflow -2
#define ml 10
typedef struct sqlist
{
int list[ml];
int size;
int maxsize;
}sqlist;
2,sqlisths.cpp
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include"sqlist.h"
//顺序表的初始化
sqlist *init_list(sqlist *L,int ms)
{
L=(sqlist*)malloc(ms*sizeof(sqlist));
if(!L)
{
printf("Memory allocation failurel\n");
exit(overflow);
}
else
L->size=0;
L->maxsize=ml;
return L;
}
3 sqlistmain.cpp
#include"sqlisths.cpp"
#include<iostream>
void main()
{
sqlist a,*b;
b=init_list(&a,ml);
printf("list=%p\tsize=%d\tmaxsize=%d\t", b->list,b->size,b->maxsize);
}
老是错,搞了几小时了还没搞好,只好请大家来帮我看看,分不是问题啊
错误提示
--------------------Configuration: sqlist - Win32 Debug--------------------
Linking...
sqlistmain.obj : error LNK2005: "struct sqlist * __cdecl init_list(struct sqlist *,int)" (?init_list@@YAPAUsqlist@@PAU1@H@Z) already defined in sqlisths.obj
Debug/sqlist.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
sqlist.exe - 1 error(s), 0 warning(s)