(1)
InitList()函数里应该是 LA.elem = new ListA[MAXSIZE]
(2)编译器提示找不到函数,应该是在调用函数的cpp中没有找到函数声明。修改方法如下:
2.1)添加一个def.h头文件:
def.h头文件内容:
#ifndef _DEF_H_
#define _DEF_H_
//把原来cpp中的类型声明都放在.h文件中
#include <iostream>
using namespace std;
#define MAXSIZE 100
#define ERROR 0
typedef struct
{
int num1;
}ListA;
typedef struct
{
ListA* elem;
int length;
}sqlist;
void InitList(sqlist &LA);
#endif
2.2)在0925v01.cpp中只保留如下内容:
#include "def.h"
void InitList(sqlist &LA)
{
LA.elem = new ListA[MAXSIZE];
LA.length = 0;
}
2.3)然后你再调用InitList()函数的cpp中include “def.h”就可以了
类型不一致啊
LA.elem = new ListA[MAXSIZE];