Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,807 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,781 people online right now. Registration is fast and FREE... Join Now!




Class Implementation

 
Reply to this topicStart new topic

Class Implementation

devilbolt
6 Feb, 2007 - 02:19 AM
Post #1

New D.I.C Head
*

Joined: 5 Feb, 2007
Posts: 9


My Contributions
// 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
User is offlineProfile CardPM
+Quote Post

devilbolt
RE: Class Implementation
6 Feb, 2007 - 04:59 AM
Post #2

New D.I.C Head
*

Joined: 5 Feb, 2007
Posts: 9


My Contributions
anyhelp from any experts out there??
thnks!
really dont understand why the prog crashed....... is it because my iterator was erased along with the function???
User is offlineProfile CardPM
+Quote Post

devilbolt
RE: Class Implementation
6 Feb, 2007 - 06:50 AM
Post #3

New D.I.C Head
*

Joined: 5 Feb, 2007
Posts: 9


My Contributions
help help!
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 08:06AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month