void Admin::searchFlight(string destination)
{
int day, month, year, min, hour,flightID;
string departure;
double price;
Flight sFlight;
string read;
Date dateOfFlight(day,month,year);
Time timeOfFlight(min,hour);
ifstream inFlight("Flight.txt");
while(!inFlight.eof())
{
inFlight.getline(read,departure);
}
int counter = 0;
for(int i = 0; i<flightList.size();i++)
{
if(destination.compare(flightList[i].getDestination()))
{
//counter++;
flightList[i].displayFlightSchedule();
}
}
}
inFlight.getline(read,departure);
之间存在错误。由于我的文件有这种类型的细节
(航班ID:1出发地:马来西亚目的地:英国此航班的价格:RM20000飞行日期:24/12/1993飞行时间:12:12)
我想在执行此代码admin.searchFlight("UK");
答案 0 :(得分:0)
您(错误地)读取了文件中的行但您没有对它们执行任何操作。您的代码应该按照
的顺序构建for (std::string departure; std::getline(inFlight, departure); ) {
do_some_thing_with(departure);
}