我正在编写一个简单的数据结构库,同时遇到了一些问题。
我写了三个文件。collections.h是头文件,collections.cpp是实现头文件中声明的方法,main.cpp是用于测试。但编译出现错误:
对 List::GetCount() const 的未定义引用;
对 List::IsEmpty() const 的未定义引用;
对 List::Add(int) 的未定义引用;
...// 等等。
我在下面提供了我的代码,问题出在哪里?
集合.h:
#ifndef COLLECTIONS_H
#define COLLECTIONS_H
#include <windows.h>
#include <stdexcept>
template<typename T>
class ISequenceList
{
protected:
ISequenceList() { }
public:
virtual int GetCount() const = 0;
virtual bool IsEmpty() const = 0;
virtual void Add(T item) = 0;
virtual void AddRange(const T *items, int length) = 0;
virtual T &ElementAt(int index);
virtual bool InsertAt(T item, int index);
virtual bool Remove(T item) = 0;
virtual bool …Run Code Online (Sandbox Code Playgroud)