Syntax problems with Class Template
I can't seem to resolve a syntax error, that is only occuring when I use a template with a pointer. Its just a basic linked list, here is the first part of my header file:
Code:
#ifndef LISTTEMP_H
#define LISTTEMP_H
#include <iostream>
template <class type>
class listtemp{
public:
const listtemp <type>& operator= (const listtemp<type>&);
void initializelist();
bool islistempty();
bool islistfull();
void print();
int length();
void destroylist ();
void retrievefirst(type& firstelement);
listtemp();
listtemp(const listtemp <type>& otherlist);
~listtemp();
protected:
nodetype<type> *first; //line 25
nodetype<type> *last;
};
template <class type>
bool listtemp<type>::islistempty(){
return (first == null);
}
template <class type>
bool listtemp<type>::islistfull(){
return false;
}
template <class type>
listtemp<type>::listtemp(){
first = NULL;
last = NULL;
}
template <class type>
void listtemp<type>::destroylist(){
nodetype<type> *temp; //line 49
}
and the error message I am getting is as follows:
Compiler: Default compiler
Building Makefile: "E:\C++Programs\Makefile.win"
Finding dependencies for file: E:\C++Programs\Sortedlistmain.cpp
Executing make...
make.exe -f "E:\C++Programs\Makefile.win" all
g++.exe -D__DEBUG__ -c Sortedlistmain.cpp -o Sortedlistmain.o -I"E:/Dev-Cpp/include/c++/3.3.1" -I"E:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"E:/Dev-Cpp/include/c++/3.3.1/backward" -I"E:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"E:/Dev-Cpp/include" -g3 -O0 -O3 -g3
In file included from sortlist.h:3,
from Sortedlistmain.cpp:3:
listtemp.h:25: error: syntax error before `*' token
listtemp.h:26: error: syntax error before `*' token
listtemp.h: In member function `void listtemp<type>::destroylist()':
listtemp.h:49: error: syntax error before `>' token
I have checked multiple references allready, and my code syntax looks the same, so I'm guessing it may be compiler related, however I am not sure. Any help is greatly appreciated.