2017-02-25 87 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之前听取错误消息并检查您的拼写!

相关问题