std::vect sorting with member variable
I'm stuck with this piece of code:
class MyObject
{
public:
int value;
}
class MyClass
{
private:
btAlignedObjectArray<MyObject*> m_objects;
public:
int comp (MyObject *a, MyObject *b)
{
return a->value < b->value;
}
void doSort()
{
m_objects.quickSort(comp);
}
};
It doesn't compile because comp is a non static member function.
comp cant be static, because it needs to access the member variable
m_objects.
Also it would defeat the encapsulation of m_objects to have a static
function and call it like this
MyClass::doSort(myClass.m_objects)
No comments:
Post a Comment