Q:

Method definition need to use private declaration of a class

I have a problem trying to create a method that its type its a private variable of her class:
foo.h
template <class T> class Foo {
  private:
    struct Node {
      T value;
      Node * following;
    }

    Node * bar( const T & elem );
}

foo.cpp
template <class T> Node * bar( const T & elem );

But Node doesn't exists in foo.cpp, because is a private variable of the class Foo foo.h.
How can I fix it?

A:

In foo.cpp you are specifying the return type and name of the function incorrectly. Node comes from the class Foo so you need to qualify it with Foo<T>::. Same goes with the member function bar:
template <class T>
typename Foo<T>::Node* Foo<T>::bar( const T & elem );
//       ^^^^^^^^      ^^^^^^^^

