ヘッダー ファイル 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 行目でエラーが発生します: expected initializer before '<' トークン
ここで何か助けはありますか?dlist.h ファイルから関数を定義することを許可していない、何か間違っていることがありますか? ありがとうございました。