list::sort for pointers

Hello,

I have list with pointers to a class object. I want to sort them by the first data member of the class. I use list::sort and my function for comparison.

I think I have put down everything correctly ,though I got error.

Help me please.

//comparison function

bool CArrange_PointsDlg::CompareVPoints (const VPoint* p1, const VPoint* p2)
{
if (p1->_x < p2->_x)
return true;
else
return false;
}

//class definition

class VPoint
{
public:
VPoint() : _x(0), _y(0), _z(0){}
VPoint(float x, float y, float z) : _x(x), _y(y), _z(z) {}
~VPoint() {}

public:
float _x;
float _y;
float _z;
};


typedef list<VPoint*> VList;
VList vL;

//sort

vL.sort<VPoint*>(CompareVPoints);



//error

error C3867: 'CArrange_PointsDlg::CompareVPoints': function call missing argument list; use '&CArrange_PointsDlg::CompareVPoints' to create a pointer to member
Do exactly as the error says to do, except that you will need to
make CompareVPoints a static function also.

Thank U!

Best regards!
Topic archived. No new replies allowed.