小编Map*_*Wan的帖子

C++ 对 List<int>::GetCount() const 的未定义引用

我正在编写一个简单的数据结构库,同时遇到了一些问题。

我写了三个文件。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)

c++ templates codeblocks

1
推荐指数
1
解决办法
3038
查看次数

标签 统计

c++ ×1

codeblocks ×1

templates ×1