我很确定这个Do While Loop应该可行。但它没有。我不知道为什么。它就停止了。如果我加!在条件面前,它只是转向无限循环。
do
{
cout <<"\nThe database details are as follow: "<< endl;
cout <<"\nSize of database = "<<sRecord.size () <<endl;
studentRecord::iterator sRecordIter;
for(sRecordIter = sRecord.begin();
sRecordIter != sRecord.end();
++sRecordIter)
cout <<
"\nStudent ID: " << sRecordIter->first <<
" Student Name: " << sRecordIter->second->getName() << endl;
cout << "\nPlease enter ID key of student to search their record." <<endl;
cin >> recordSearch;
searchDatabase(sRecord,recordSearch);
for(sRecordIter = sRecord.begin();
sRecordIter != sRecord.end();
++sRecordIter)
if (recordSearch == sRecordIter->second->getId())
{
sRecordIter->second->printCourseInfo();
}
cout <<"Would you like to search the database again y/n?"<<endl; // Ask user if they want to continue
cin >> cont;
}
while ((cont == 'Y' || cont == 'y'));