A
Andreas Schmitt
Hi,
with myTeam being a vector of pointers to a class 'Team'
std::vector<Team*> myTeam;
I tried to use these two methods in the class 'League'
void League::CalculateTable( void )
{
std::stable_sort( myTeam.begin(), myTeam.end(),
TeamIsBetter );
}
bool League::TeamIsBetter( Team* Team1, Team* Team2 )
{
int PointsTeam1 = Team1->GetPoints();
int PointsTeam2 = Team2->GetPoints();
int TotGoalsTeam1 = Team1->GetTotGoals();
int TotGoalsTeam2 = Team2->GetTotGoals();
int PosGoalsTeam1 = Team1->GetPosGoals();
int PosGoalsTeam2 = Team2->GetPosGoals();
if ( PointsTeam1 != PointsTeam2 )
{
return PointsTeam1 > PointsTeam2;
}
else
{
if ( TotGoalsTeam1 != TotGoalsTeam2 )
{
return TotGoalsTeam1 > TotGoalsTeam2;
}
else
{
return PosGoalsTeam1 > PosGoalsTeam2;
}
}
}
This produces "error C2064: term does not evaluate to a function taking 2
arguments" in <algorithm> at 3 points which contain ' if (_Pred(*_Mid,
*_First)) '
It worked before when I called the stable_sort directly from the main()
function and had the TeamIsBetter() function also defined as a function for
the main() function.
I didn't change anything in the TeamIsBetter() function and I call the
stable_sort() function just the way I did before..
Now that I tried to pack those into a class it doesn't seem to work anymore,
and I don't know that the error wants to tell me in this context...
Anyone with an idea what's the problem here?
Thanks
with myTeam being a vector of pointers to a class 'Team'
std::vector<Team*> myTeam;
I tried to use these two methods in the class 'League'
void League::CalculateTable( void )
{
std::stable_sort( myTeam.begin(), myTeam.end(),
TeamIsBetter );
}
bool League::TeamIsBetter( Team* Team1, Team* Team2 )
{
int PointsTeam1 = Team1->GetPoints();
int PointsTeam2 = Team2->GetPoints();
int TotGoalsTeam1 = Team1->GetTotGoals();
int TotGoalsTeam2 = Team2->GetTotGoals();
int PosGoalsTeam1 = Team1->GetPosGoals();
int PosGoalsTeam2 = Team2->GetPosGoals();
if ( PointsTeam1 != PointsTeam2 )
{
return PointsTeam1 > PointsTeam2;
}
else
{
if ( TotGoalsTeam1 != TotGoalsTeam2 )
{
return TotGoalsTeam1 > TotGoalsTeam2;
}
else
{
return PosGoalsTeam1 > PosGoalsTeam2;
}
}
}
This produces "error C2064: term does not evaluate to a function taking 2
arguments" in <algorithm> at 3 points which contain ' if (_Pred(*_Mid,
*_First)) '
It worked before when I called the stable_sort directly from the main()
function and had the TeamIsBetter() function also defined as a function for
the main() function.
I didn't change anything in the TeamIsBetter() function and I call the
stable_sort() function just the way I did before..
Now that I tried to pack those into a class it doesn't seem to work anymore,
and I don't know that the error wants to tell me in this context...
Anyone with an idea what's the problem here?
Thanks