本文整理汇总了C++中Patron::setID方法的典型用法代码示例。如果您正苦于以下问题:C++ Patron::setID方法的具体用法?C++ Patron::setID怎么用?C++ Patron::setID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patron
的用法示例。
在下文中一共展示了Patron::setID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildPatrons
/*
---------------------------------buildPatrons--------------------------------
buildPatrons - creates patrons from the data file and hands them to the
library to appropriately manage.
PreConditions: File must be in the valid format, defined for Assignment #3.
PostConditions: Every line is read, processed, and each patron generated from
the process is handed to the library to insert into the
data structures.
*/
void Manager::buildPatrons() {
int inputID = -1;
std::string inputName;
//While we have stuff to process from the data file...
while(!patronsStream.eof()) {
inputID = -1;
patronsStream >> inputID;
//Is the Patron ID valid?
if(inputID >= 0 && inputID < MAX_PATRON_SIZE) {
//Yes! Let's process the input data and add them to the patron
//data structure.
patronsStream.get();
getline(patronsStream, inputName);
Patron* inputPatron = new Patron();
inputPatron->setName(inputName);
inputPatron->setID(inputID);
bool inserted = MyLibrary.insert(inputPatron);
//delete inputPatron if we are unable to insert them
if(inserted == false) {
delete inputPatron;
}
inputPatron = NULL;
inputID = -1;
//Patron ID is invalid, so we throw away the rest of the line.
} else {
getline(patronsStream, inputName);
}
}
patronsStream.close();
}