我正在编译一个项目,在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