我正在編譯一個項目,在RHEL 5.0下的linux 3下編譯,因此使用gcc編譯器版本4.1.1。 我有一行這樣的錯誤:ISO C++禁止聲明沒有類型的「節點」
inline Tree<ExpressionOper<T> >::Node* getRootNode() const throw() { return m_rootPtr; }
按照包括在上面的tree.h中,這裏是一個類的模板聲明:
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;
};
提前非常感謝。
啊哈哈 - 你剛到那裏第一次......更好的解釋,但! – Nick 2011-03-10 16:26:47
@Nick:Teeheehee :) – 2011-03-10 16:27:13