template <class T>
class Llist
//....

//Iterates to position and sets pointers to node at position-1 and position.
template <class T>
void LList<T>::iterate(Node<T>*& previous, Node<T>*& next, unsigned short pos)
{
   //some code
}

//Start Iterator
template <class T>
inline Iterator<T> LList<T>::start()
{
   //some code
}

template <class T>
class Iterator
{
   Node<T> *pointer;
//......
}

template <class T>
class Node
{
   T data
//....
}

This is a linked list template class using template classes of node and iterator.
I'm having problems with these method headers. gcc is giving me error on the header lines:
expected initializer before ‘<’ token

That's the only error I'm getting and only in those functions. And those are the only functions with multiple templated types in the headers. So I'm assuming it has something to do with that. How should I declare these?

thank you
*Please exuse me for not pasting all of my code I don't want somebody in my class to see this and copy me.

Recommended Answers

All 4 Replies

Your declaration of Node should come before your declaration of LList. The compiler doesn't know what Node<T> is because this class is only declared later. When it says "expected initializer before < token", it just means that it didn't recognize "Node" in front of "<T>".

No I'm sorry these are defined in seperate files: LLlist.h, Node.h, and Iterator.h
I'm not having problems using these classes in my other methods. I am only having problems with these methods I just implemented, and it is only giving me an error on the line at their method header. I'm not using any other templated classes as parameters or return types in my other methods, so I'm just wondering if that has something to do with it.

NEVERMIND. solved. I hate to even say what the problem was it's that bad. Just another reminder that c++ is case sensitive......
LList != Llist

Are you expecting the above code to compile?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.