i have this part of my link list program

template <class E> LinkedList<E>::node * LinkedList<E>::getNode{
...
...
}(const E &item)

and my compiler, bloodshed dev c++, says
expected constructor, destructor, or type conversion before "*" token
expected ";" before "*" token

i don't think there is an syntax error but can someone explain this..

Edited 6 Years Ago by qupav: n/a

opps, sorry there is a mistake while posting it here..ill edit it..

it is actually

template <class E> LinkedList<E>::node * LinkedList<E>::getNode(const E &item)
{
//some lines here
}

Edited 6 Years Ago by qupav: n/a

Do you have the method definitions in the same header file with the declarations? It kinda runs counter to your experience with headers but for templates it's usually necessary.

Do you have the method definitions in the same header file with the declarations? It kinda runs counter to your experience with headers but for templates it's usually necessary.

yup..i declared it my class right after the declaration of the struct

something like this

//template class declaration
{
      struct node {

      }
      node *getNode (/*parameters*/);//here is the declaration on the very the same header file
};

actually this is a class on linked lists..

i'm sorry but i don't understand what you mean by "It kinda runs counter to your experience with headers but for templates it's usually necessary"

Try it as template <class E> typename LinkedList<E>::node * LinkedList<E>::getNode(const E &item) since I believe the situation is equivalent (or at least parallel to) this thread.

i'm sorry but i don't understand what you mean by

No, not a problem at all. I just meant that classically people put declarations, defines, etc. in the header file and leave the implementation to a separate .cpp file whereas with templates all of that (declarations, definitions, etc) together has to get lumped in the same .h file with almost all compilers.

Edited 6 Years Ago by jonsca: n/a

This question has already been answered. Start a new discussion instead.