-2

我对“从这里实例化”有疑问。

template <typename E>
class tree
{
public:
    tree(){root=0;}
    void addAVL( const E &data) throw(bad_alloc);
private:
    class Node
    {
    public:

        E data;             
        Noeud * left;       
        Noeud * right;      
        int high;       
        std::string adHier; 

        Noeud( const E&d ): data( d right( 0 ),left( 0 ),high(0), adHier("") { }
    };
    Node * root;
};

#include "AVL.inl"

/*-------------------------
*in my inl
*/
template <typename E>
void tree<E>::addAVL( const E &data) throw(bad_alloc)
{
    // if the trre is empty
    if ( root == 0 )
    {
        root = new Node(data);  // HERE my error when in a cpp I call addAVL
    }
}

我的错误是:

../AVL.inl:98:   instantiated from ‘void AVL_Lab10::tree<E>::addAVL(const E&) [with E = int]’
../TestingAVL.cpp:30:   instantiated from here
4

2 回答 2

3
Noeud * left;
Noeud * right;
Noeud( const E&d ): ...

我想应该Node不是Noeud吧?如果您更正了这些错别字,它会修复您的错误吗?

于 2011-04-14T03:05:33.050 回答
0

最后我没有找到问题,但我可以构建......我的老师说我在 Eclipse 中使用 gcc 编译器有相同的问题。这很好奇,因为每次我在 .inl 中添加一些代码并保存。错误图标显示....

感谢您的帮助 !:D

于 2011-04-16T00:29:03.207 回答