Sort not working?

Hey, I'm trying to sort a list of objects but keep getting errors due to converting parameters. Heres the code:

1
2
3
4
5
6
7
bool SortThis(Objects & first, Objects & second)
{
    return first.a < second.a;
}

list<Objects*> object1;
object1.sort(SortThis);


The error is:
'bool (Objects &,Objects &)' : cannot convert parameter 1 from 'Objects *' to 'Objects &'

Any help?
1
2
3
4
bool SortThis(Objects * first, Objects * second)
{
    return first->a < second->a;
}
Your compiler tells you that you try to use a function with wrong arguments:
Object * instead of Object &

 
list<Objects*> object1;

You are defining an empty list containing pointers to Objects (empty one)

object1.sort(SortThis);
The you call member function sort of Object (no more information given). With an argument a function. Is this really the correct argument of sort?

At what line the error occurs? Can you be more specific?
Last edited on
Topic archived. No new replies allowed.