|
// in my tournament .h file void RemoveTeam(string name);
// in my tournament.cpp file. // To remove the loser of each match using an iterator. void Tournament::RemoveTeam(string name) { bool found = false; list<TournamentTeam>::iterator teamptr = theTeams.begin(); while (!found && (teamptr != theTeams.end())) { if ((teamptr -> getName()) == name) found = true; else teamptr++; } if (found) { theTeams.erase(teamptr); } }
//my main int main() { Tournament team; list<TournamentTeam> theTeams; . . . cin >> L1_1>> L1_2; cin >> L2_1>> L2_2; T_1 = L1_1 + L2_1; T_2 = L1_2 + L2_2;
list<TournamentTeam>::iterator teamptr = theTeams.begin(); if (G_T_1 < G_T_2) { team.RemoveTeam(teamptr -> GetName()) } }
and aft i run it my prog crashes i believe it has smt to do wif that remove line. any help is much appreciated. newbie here in c++;
This post has been edited by devilbolt: 6 Feb, 2007 - 02:26 AM
|