ISO C ++ forbids declaration of 'Node without type

I am porting a project compiled under linux 3 to RHEL 5.0, so with the gcc compiler version 4.1.1. I got this error in the line:

inline Tree<ExpressionOper< T > >::Node* getRootNode() const throw() { return m_rootPtr; }

Follow tree.h included at the top, where is the class template declaration:

template <typename T>
class Tree
{
public:
class Node
  {
  public:

    Node ()
      : _parent (NULL) {};

    explicit Node (T t)
      : _parent (NULL)
      , _data (t) {};

    Node (T t, Node* parent)
      : _parent (parent)
      , _data (t) {}; 

    ~Node()
    {
      for (int i = 0; i < num_children(); i++){
        delete ( _children [ i ] );
      }
    }; 

    inline T& data()
    {  
      return ( _data);          
    };  

    inline int num_children() const 
    {  
      return ( _children.size() );    
    };

    inline Node* child (int i)
    {
      return ( _children [ i ] );    
    };


    inline Node* operator[](int i)
    {  
      return ( _children [ i ] );    
    };

    inline Node* parent()
    {
      return ( _parent);
    };

    inline void set_parent (Node* parent)
    {
      _parent = parent;
    };

    inline bool has_children() const
    {
      return ( num_children() > 0 );
    };

    void add_child (Node* child)
    {
      child -> set_parent ( this );
      _children.push_back ( child );
    };

  private:
    typedef std::vector <Node* > Children;
    Children  _children;
    Node*     _parent;
    T         _data;

  }; 

Thank you very much in advance.

+3
source share
2 answers

Try the following and read this :

inline typename Tree<ExpressionOper< T > >::Node* getRootNode() const throw()
{
    return m_rootPtr;
}

, ExpressionOper<T> , , Tree<ExpressionOper<T> > ( T). , , Tree<ExpressionOper<T> >::Node. typename, , , . .

, , - : , , , "Node" Tree<ExpressionOper< T > >, , , , .

+5

, typename:

inline typename Tree<ExpressionOper< T > >::Node* etc...
+1

All Articles