部分头文件 dlist.h 定义为:
#ifndef __DLIST_H__
#define __DLIST_H__
#include <iostream>
class emptyList {};
template <typename T>
class Dlist {
 public:
    bool isEmpty() const;
 private:
    struct node {
    node   *next;
    node   *prev;
    T      *o;
    };
    node   *first; // The pointer to the first node (NULL if none)
    node   *last;  // The pointer to the last node (NULL if none)
};
#include "dlist.cpp"
#endif
当我像这样创建 dlist.cpp 文件时:
#include "dlist.h"
template <typename T>
bool Dlist<T>::isEmpty() const
{
    return !first and !last;
}
我在第 4 行收到错误消息:重新定义 'bool Dlist::isEmpty() const'
如果我删除第#include "dlist.h"4 行的错误:在 '<' 标记之前的预期初始化程序
这里有什么帮助吗?我做错了什么,不允许我从 dlist.h 文件中定义我的函数吗?谢谢你。