I am new to C++ and am trying to create a doubly linked list using templates, here is the code
doubleLinkedList.h
#ifndef DOUBLELINKEDLIST_H_
#define DOUBLELINKEDLIST_H_
#include<iostream>
#include"nodeType.h"
using namespace std;
template <class Type>
class doubleLinkedList
{
public:
void initList();
bool isEmptyList() const;
void destroy();
void print() const;
void reversePrint() const;
int length() const;
Type front() const;
Type back() const;
bool search(const Type& searchItem) const;
void insert(const Type& insertItem);
void deleteNode(const Type& deleteItem);
doubleLinkedList();
protected:
int count;
nodeType<Type> *first;
nodeType<Type> *last;
};
#endif /* DOUBLELINKEDLIST_H_ */
nodetype.h
#ifndef NODETYPE_H_
#define NODETYPE_H_
#include<iostream>
using namespace std;
template <class Type>
struct nodeType
{
Type info;
nodeType<Type> *next;
nodeType<Type> *back;
};
#endif /* NODETYPE_H_ */
the implementation file
#include<iostream>
#include"doubleLinkedList.h"
#include"nodeType.h"
using namespace std;
template <class Type>
doubleLinkedList<Type>::doubleLinkedList()
{
first= NULL;
last = NULL;
count = 0;
}
template <class Type>
Type doubleLinkedList<Type>::front() const
{
assert(first != NULL);
return first->info;
}
template <class Type>
Type doubleLinkedList<Type>::back() const
{
assert(last != NULL);
return last->info;
}
and the driver
#include<iostream>
#include"doubleLinkedList.h"
#include"nodeType.h"
using namespace std;
int main()
{
doubleLinkedList<int> testOne;
cout << "working" << endl;
system("pause");
return 0;
}
Not completely finished, but I keep getting a " [Linker error] undefined reference to `doubleLinkedList<int>::doubleLinkedList()' " using devC++ (required by the course) Anyone know how to fix this?