本文整理汇总了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;
}
示例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;
}
示例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++;
}