Part of the header file dlist.h is defined as:
#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
When I create a dlist.cpp file like this:
#include "dlist.h"
template <typename T>
bool Dlist<T>::isEmpty() const
{
return !first and !last;
}
I get the error message at line 4: redefinition of 'bool Dlist::isEmpty() const'
If I remove the #include "dlist.h"
I get the error at line 4: expected initializer before '<' token
Any help here? Is there something I'm doing wrong that's not allowing me to just define my functions from the dlist.h file? Thank you.