当前位置: 首页>>代码示例>>C++>>正文


C++ Country::getCode方法代码示例

本文整理汇总了C++中Country::getCode方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::getCode方法的具体用法?C++ Country::getCode怎么用?C++ Country::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Country的用法示例。


在下文中一共展示了Country::getCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deleteNode

bool CountryList::deleteNode(Country &nodeData)
{
   ListNode *nodePtr;       // To traverse the list
   ListNode *previousNode;  // To point to the previous node

   // Initialize nodePtr to head of list
   nodePtr = head->next;
   previousNode = head;

   // Skip all nodes whose code is not equal to the code pointed by pDeleteCode.
   while (nodePtr != NULL && strcmp(nodePtr->country.getCode(), nodeData.getCode()) != 0)
   {
      previousNode = nodePtr;
      nodePtr = nodePtr->next;
   }

   // If node-to-delete not found OR no nodes
   if (!nodePtr)
      return false;
   
   nodeData = nodePtr->country;  // return the deleted data
   previousNode->next = nodePtr->next;
   delete nodePtr;
   count--;
   return true;
}
开发者ID:tingting0826,项目名称:Build-and-process-a-linkedList,代码行数:26,代码来源:CountryList.cpp

示例2: searchNode

//**************************************************
// The searchNode function searches for a node     *
// with nodeData.code. If the node was found       *
// then true is returned and the Country data of   *
// node found is returned in nodeData. If the node *
// was not found, then false is returned and       *
// nodeData reference variable is unchanged.       *
//**************************************************
bool CountryList::searchNode(Country &nodeData)
{
   ListNode *nodePtr;            // To traverse the list

   // Position nodePtr at the head of list.
   nodePtr = head->next;

   // Skip all nodes that doesn't matches code of nodeData
   while (nodePtr != NULL && strcmp(nodePtr->country.getCode(), nodeData.getCode()) != 0)
   {
      // Move to the next node
      nodePtr = nodePtr->next;
   }

   // If nodePtr is NULL (not found)
   if (!nodePtr)
      return false;

   // Load nodeData with data from the found node
   nodeData = nodePtr->country;
   return true;
}
开发者ID:tingting0826,项目名称:Build-and-process-a-linkedList,代码行数:30,代码来源:CountryList.cpp

示例3: insertNode

void CountryList::insertNode(Country countryIn)
{
   ListNode *newNode;             // A new node
   ListNode *nodePtr;             // To traverse the list
   ListNode *previousNode = head; // The previous node

   // Allocate a new node and store countryIn there.
   newNode = new ListNode;
   newNode->country = countryIn;

   // Position nodePtr at the head of list.
   nodePtr = head->next;

   // Skip all nodes whose value is less than code.
   while (nodePtr != NULL && strcmp(nodePtr->country.getCode(), countryIn.getCode())<0)
   {
      previousNode = nodePtr;
      nodePtr = nodePtr->next;
   }
   previousNode->next = newNode;
   newNode->next = nodePtr;
   count++;
}
开发者ID:tingting0826,项目名称:Build-and-process-a-linkedList,代码行数:23,代码来源:CountryList.cpp


注:本文中的Country::getCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。