In order to use compById
as a parameter to std::sort
it should not be a member function. This is wrong
class Square
{
bool compById(Square* a, Square* b)
{
return a->getId() < b->getId();
}
...
};
This is better,
class Square
{
...
};
bool compById(Square* a, Square* b)
{
return a->getId() < b->getId();
}