2011-04-14 82 views
-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

請重新格式化您的問題。 – 2011-04-14 03:00:22

+1

根 - 您可以通過縮進4個空格來格式化代碼。最簡單的方法是突出顯示您的代碼部分,然後單擊編輯器中的「{}」按鈕。 – 2011-04-14 03:04:19

+2

實際的錯誤信息可能就是編譯器輸出中'從此處'實例化後的行* * – phooji 2011-04-14 03:07:06

回答

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

我想這應該是NodeNoeud?如果你糾正了這些錯別字,它是否能解決你的錯誤?

+0

除此之外,Node也是一個私有的內部類。 – phooji 2011-04-14 03:09:26

+0

@phooji:沒有錯,因爲它是一個私有的內部類'''',它應該是唯一使用它的類。 – Xeo 2011-04-14 03:18:56

+0

啊我滾動下來看到實例化是一個樹成員:)但仍然不會是我的設計選擇,但 - 硬(呃)以後調整分配這種方式。 – phooji 2011-04-14 03:31:27

0

finaly我沒有找到概率,但我可以建立...我的教導說,他有食物中的gcc compilator samme概率。它非常好奇,因爲每次我在.inl中添加一些代碼並保存。錯誤圖標顯示....

謝謝你的幫助! :D