我们在写程序的大部分时间都不会去考虑在已有的知识上出现的匮乏,前两天用C++写了一个顺序表,结果却不尽人意,这个或许是因为人生就是这样,在你已知的知识当中出现的知识漏洞你会很难发现,这里还是感谢一下syc大哥,每次在VC驿站上发帖子,他都给我回复了,也就是syc让我更加的喜欢VC驿站。
行了,谈谈出现的错误
这里是我之前出错的代码
http://www.cctry.com/thread-256893-1-1.html
这里我放上了我成功后的代码
SeqList.h
#include<iostream>
#include<stdio.h>
//默认的顺序表大小
const int defaultsize= 10;
//类
template<typename DateType>
class SeqList
{
public:
SeqList(int size = defaultsize)
{
//判断对应的顺序表长度
if (size > 0)
{
maxSize = size;
//数据数组
eml = new DateType[size];
}
}
//析构函数
~SeqList()
{
//申请的数组不为空时进行释放
if (eml != NULL)
{
delete []eml;
eml = NULL;
}
}
int getLength()
{
return curLength;
}
//插入
bool insertElem(DateType e);
//删除
bool delElem(int index);
//查找
DateType fin