2017-02-25 50 views
-4

我已聲明這個函數 /////////////// //////////////////////////////類節點沒有任何成員

template<class ItemType> 
LinkedBag<ItemType> LinkedBag<ItemType>::bagUnion(LinkedBag<ItemType> otherBag) 
{ 
    LinkedBag<ItemType> unionBag; // create a new Bag 

    Node<ItemType>* curPtr = headPtr; // get a pointer to the beginning of the invoking bags list 
    for(int i=0; i<getCurrentSize(); i++) // for each item in the list ... 
    { 
     unionBag.add(curPtr->getItem()); // add the item to the new bag 
     curPtr = curPtr->getNext(); // cycle to the next item (needed for linked list) 
    } 

    curPtr = otherBag.headPtr; 
    for(int j=0;j<otherBag.getCurrentSize(); j++) 
    { 
     unionBag.add(curPtr->getItems()); //add the item to unionBag 
     curPtr = curPtr->getNext();// cycle to the next Item 
    } 
return unionBag; 
} 

///////////// ////////////////////////// 這是我得到的錯誤 BagTester.cpp:70:56:從這裏需要 LinkedBag.cpp: 244:7:error:'class Node>'has no member named'getItems()'

+2

這聽起來像錯誤信息告訴你什麼問題已經......我建議你聽你的編譯器。 – tmpearce

+0

問題出在第二個循環unionBag.add(curPtr-> getItems()); 「沒有名爲'getItems()'的成員 –

回答

0

您犯了一個錯字。你寫了getItems而不是getItem

請在發佈問題到Stack Overflow之前聽取錯誤消息並檢查您的拼寫!

相關問題