I have a private comparator in Level class:
bool positionCmp(Entity* a, Entity* b);
and when I try to use this in another Level class method:
void Level::drawEntities(std::vector<Entity*> entities)
{
sort(entities.begin(), entities.end(), positionCmp);
for (int i = 0; i < entities.size(); ++i) entities[i]->draw();
}
Visual Studio 2019 compiler says:
'Level::positionCmp': non-standard syntax; use '&' to create a pointer to member
.
If I add the '&', I getting '&': illegal operation on bound member function expression
void Level::drawEntities(std::vector<Entity*> entities)
{
sort(entities.begin(), entities.end(), &positionCmp);
for (int i = 0; i < entities.size(); ++i) entities[i]->draw();
}
What should I do?