template error


I am doing a linked list program in cpp . I am getting an error at line 7 saying that start_list is not a template.what is the wrong I am doing?
But this code as it is in a text book :

#include<iostream>
using namespace std;

1.template<class node>
2.class list
3.{
4 private :
5
6 list<node> *next;
7 friend class start_list<node>;
8 friend class iterator<node>;
9
public :
node data;
};

template<class node>
class start_list
{
list<node> *start;
friend class iterator<node>;

public :
start_list(void){
start = NULL;
}
~start_list(void);

void add(node t);

int isMember(node t);
}

int main()
{
cout<<"Hello world"<<endl;
system("pause");
return 0;
}
Are you trying to use std::iterator ?
http://www.cplusplus.com/reference/std/iterator/iterator/
In that case read the reference page, as it's working in a different way.

If not, than where it is defined?
Also you have to forward declare template class start_list<node>; before class list

Also you're missing a semi-colon after the definition of class start_list.

After removing the lines with iterator and forward declaration it compiled for me.

And next time please use [code][/code] tags.
Topic archived. No new replies allowed.