我有一份囚犯记录的文本文件:
Roy MOYES ARSON 35
Damien SIEBERT OTHER 37
Nigel COMYN ROBBERY 46 59000
Gai CRABBE OTHER 95
Stacey BEGLEY OTHER 80
我试图把它读成囚犯的一个阶级对象:
void Prison::ReadCrimFile(){
ifstream fin;
fin.open("crims.txt");
if(!fin.good())
cerr << "File not found!\n" << endl;
else
while(!fin.eof()){
fin >> FirstName >> FamilyName >> Crime >> Months;
Criminal* C = new Criminal(FirstName, FamilyName, Crime, Months, i);
Crims.insert(C);
}
fin.close();
cout << "There are" << " " << Crims.size() << " " <<"criminals on
record" << endl;
}
当我运行它虽然它最后没有产生任何输出时,只是在控制台窗口中闪烁光标