I'm working in a class function:
void Planner::CellSort()
{
vector<vector<int>> *pointer_to_open = &openlist;
sort(pointer_to_open->begin(), pointer_to_open->end(), Compare);
}
When I try to compile it I get the following error:
error: must use '.*' or '->*' to call pointer-to-member function
But When I try the following compile just fine:
sort((&openlist)->begin(), (&openlist)->end(), Compare);
Isn't both actually doing the same? or what's the difference between those two approaches.
This is my Compare function:
bool Planner::Compare(const vector<int> a, const vector<int> b)
{
int f1 = a[2] + a[3]; // f1 = g1 + h1
int f2 = b[2] + b[3]; // f2 = g2 + h2
return f1 > f2;
}
Thank you.