我很困惑为什么不能使用二元运算符比较指向成员的指针<
class Point3d{
protected:
//..
public:
float x;
static list<Point3d*> *freeList;
public:
float y;
static const int chunkSize = 250;
public:
float z;
};
和一个模板:
template< class class_type, class data_type1, class data_type2 >
char* access_order(data_type1 class_type:: *mem1, data_type2 class_type:: *mem2)
{
return
mem1 < mem2 ?
"member 1 accurs first":
"member 2 accurs first";
}
当我像下面这样调用 access_order 时:
access_order(&Point3d::z, &Point3d::y);
g++ 报告:
"invalid operands of types ‘float Point3d::*’ and ‘float Point3d::*’ to binary ‘operator<’"
有没有办法比较指向成员的指针,我的意思是不相等的比较,以及如何?