类节点没有命名成员

Class node has no member named

本文关键字:成员 节点      更新时间:2023-10-16

我已声明此功能

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:错误:'class node>'没有名为'getItems()'

的成员

您制作了错字。您写了getItems而不是getItem

请收听错误消息并在发布问题以堆叠溢出之前检查您的拼写!