2017-04-03 63 views
0

我試圖編程AVL樹和我得到這個錯誤,我不明白,可以有人幫忙。謝謝我不明白,在聲明中錯誤信息的AVL樹

source

enter image description here

template<class KeyType, class ItemType> 
class AVL 
{ 
protected: 
template<class KeyType, class ItemType> 
class AVLNode 
{ 
    public: 
    AVLNode(KeyType key, ItemType item) : 
    m_Balance(0), m_Depth(0), 
    m_Key(key), m_Data(item), 
    m_pLeft(0), m_pRight(0) 
    { 
    } 

    KeyType  m_Key; 
    ItemType m_Data; 

    AVLNode* m_pLeft; 
    AVLNode* m_pRight; 
    }; 

    AVLNode<KeyType, ItemType>* m_pRoot; 
    public: 
    AVL() : m_pRoot(0) { } 
    ~AVL() { } 
}; 

回答

1

這些變化試試:

template<class KeyType, class ItemType> 
class AVL 
{ 
protected: 
// Unnecessary -> template<class KeyType, class ItemType> 
class AVLNode 
{ 
    public: 
    AVLNode(KeyType key, ItemType item) : m_Balance(0), m_Depth(0), 
              m_Key(key), m_Data(item), 
              m_pLeft(0), m_pRight(0) 
    { } 

    private: 
    int m_Balance; // Missing from the ctor declaration 
    int m_Depth; // Missing from the ctor declaration 
    KeyType m_Key; 
    ItemType m_Data; 

    AVLNode<KeyType, ItemType>* m_pLeft; // Change here 
    AVLNode<KeyType, ItemType>* m_pRight; // Change here 
    }; 

    AVLNode<KeyType, ItemType>* m_pRoot; 
    public: 
    AVL() : m_pRoot(0) { } 
    ~AVL() { } 
}; 
+0

有用嗎?現在有什麼錯誤? – 0xDEFACED

+0

我有更多的錯誤 –

+0

這聽起來像一個與圖像無關的錯誤。 – 0xDEFACED