main.cpp
#include <iostream>
#include "LinkList.h"
#include "StaticList.h"
using namespace std;
using namespace DTLib;
/* 测试二: */
class Test : public Object
{
int i;
public:
Test(int v = 0)
{
i = v;
}
bool operator == (const Test& obj)
{
return (i == obj.i);
}
};
int main()
{
Test t1(1);
Test t2(2);
Test t3(3);
LinkList<Test> list; // 单链表对象想要保存的元素是Test对象,并没有查找,但是编译还是会出错,不得已需要重载 ==
// 两全其美的方法: 在顶层父类中实现 == 和 !=,,然后自定义类类型继承于Object
list.insert(t1);
list.insert(t2);
list.insert(t3);
cout << list.find(t3) << endl;
return 0;
}
/* 测试一:
int main()
{
LinkList<int> list;
for(int i=0; i<5; i++)
{
list.insert(0,i);
}
cout << list.find(-3) << endl;
return 0;
}
*/